A NSData Category for Encrypting and Decrypting NSData with AES256 & AES128 alongwith optional IV(Initialization Vector).
- Category Based for existing compatibility
- Uses native CommonCryptor class, for better efficiency and future support
- Add NSData+Encryption Folder to Project (Preferred to 'Use Groups' and 'Copy Items if Needed').
- Import Category and Use with NSData Objects.
Code:
#import "NSData+Encryption.h"
// Cast the desired object to NSData object for encrypting
NSData *encryptedData = [inputNSDataObj AES256EncryptWithKey:@"!npu+K3y"]:
// Send/Save data to desired location
// Decrypting
NSData *decryptedData = [encryptedData AES256DecryptWithKey:@"!npu+K3y"]:
// Cast and format and show the desired data to user