-
-
Save jozsef-vesza/fb2c2e75c022a00192a7 to your computer and use it in GitHub Desktop.
in-place encryption attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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