Skip to content

Instantly share code, notes, and snippets.

@jozsef-vesza
Created May 19, 2014 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jozsef-vesza/fb2c2e75c022a00192a7 to your computer and use it in GitHub Desktop.
Save jozsef-vesza/fb2c2e75c022a00192a7 to your computer and use it in GitHub Desktop.
in-place encryption attempt
- (BOOL)encryptWithKey:(NSString *)key
{
// ... key generation
CCCryptorRef encryptor;
CCCryptorStatus encryptionStatus = CCCryptorCreate(kCCEncrypt, kCCAlgorithmAES128, kCCOptionECBMode, keyPtr, kCCKeySizeAES256, NULL, &encryptor);
if (encryptionStatus != kCCSuccess)
{
MCLog(@"Failed to create a cryptographic context (%d CCCryptorStatus status).", encryptionStatus);
}
size_t numberOfBytesWritten;
encryptionStatus = CCCryptorUpdate(encryptor, [self mutableBytes], [self length], [self mutableBytes], [self length], &numberOfBytesWritten);
CCCryptorRelease(encryptor);
free(keyPtr);
return ( encryptionStatus == kCCSuccess );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment