New to iOS dev, trying to work on encoding data for secure data storage in db.
I found the current example here: https://github.com/RNCryptor/RNCryptor-objc
This is my code.
NSString * aPassword =@"tempkey";
NSData *data = [@"Data" dataUsingEncoding:NSUTF8StringEncoding];
NSData *encryptedData = [RNEncryptor encryptData:data
NSLog(@"Data: %@", [[NSString alloc] initWithData:encryptedData encoding:NSUTF8StringEncoding]);
2016-10-20 11:41:52.662 BlueBoard[57245:10027277] Data: (null)
Your issue isn't that
nil, it's that you are attempted to create an
NSString from data that doesn't represent a string.
If you wish to convert
encryptedData into a string for storage or other purposes, you should convert the data into a Base 64 encoded representation. Do this with the
NSString *base64String = [encryptedData base64EncodedStringWithOptions:0];
Of course when you want to decrypt the string later, you will need to convert the Base 64 encoded string back into
NSData, and then decrypt that data.