Search code examples
iphoneiossecurityios5ios6

Encrypt and Decrypt Password in iOS


I want to encrypt password in iOS.

NSData *dataIn = [@"Now is the time for all good computers to come to the aid of their masters." dataUsingEncoding:NSASCIIStringEncoding];
NSMutableData *macOut = [NSMutableData dataWithLength:CC_SHA256_DIGEST_LENGTH];

CC_SHA256(dataIn.bytes, dataIn.length,  macOut.mutableBytes);

NSLog(@"dataIn: %@", dataIn);
NSLog(@"macOut: %@", macOut);

I want to create with a specified key. Is there any way to do this.

Thanks.


Solution

  • If can use NSString you can download NSString Additions.

    Good Tutorial here