There is a Common Crypto API.
#import <CommonCrypto/CommonCryptor.h> + (NSData *)doCipher:(NSData *)dataIn iv:(NSData *)iv key:(NSData *)symmetricKey context:(CCOperation)encryptOrDecrypt { CCCryptorStatus ccStatus = kCCSuccess; size_t cryptBytes = 0; // Number of bytes moved to buffer. NSMutableData *dataOut = [NSMutableData dataWithLength:dataIn.length + kCCBlockSizeAES128]; ccStatus = CCCrypt( encryptOrDecrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, symmetricKey.bytes, kCCKeySizeAES128, iv.bytes, dataIn.bytes, dataIn.length, dataOut.mutableBytes, dataOut.length, &cryptBytes); if (ccStatus != kCCSuccess) { NSLog(@"CCCrypt status: %d", ccStatus); } dataOut.length = cryptBytes; return dataOut; }
Also add Security.framework to your project.
If security is important, consider having someone with security experience write code and a protocol. If security is not important, just send the password to the box.
Several errors in the application are not so bad, the application still basically works, one security error and all security is lost.
Good security is not as easy as you might think.
source share