Skip to content

Commit

Permalink
Set %@_encrypted to false when encryption failed
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslawzygmunt committed Nov 1, 2019
1 parent ab116c2 commit a906af9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions SuplaApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ +(SAApp*)instance {

-(void) encryptData:(NSData *)data andSaveWithPrefKey:(NSString *)pref_key {
@synchronized(self) {
data = [data aes128EncryptWithDeviceUniqueId];
[[NSUserDefaults standardUserDefaults] setValue:data forKey:pref_key];
[[NSUserDefaults standardUserDefaults] setBool:true forKey:[NSString stringWithFormat:@"%@_encrypted", pref_key]];
NSData *encryptedData = [data aes128EncryptWithDeviceUniqueId];
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud setValue:(encryptedData != nil ? encryptedData : data) forKey:pref_key];
[ud setBool:(encryptedData != nil) forKey:[NSString stringWithFormat:@"%@_encrypted", pref_key]];
}
}

Expand Down

0 comments on commit a906af9

Please sign in to comment.