NSString *password=@"mypassword" ;
NSString *str = txtPassword.text;
// 1) Encrypt
NSLog(@"encrypting string = %@",str);
NSData *data = [str dataUsingEncoding: NSASCIIStringEncoding];
NSData *encryptedData = [data AESEncryptWithPassphrase:password];
// 2) Encode Base 64
// If you need to send over internet, encode NSData -> Base64 encoded string
[Base64 initialize];
NSString *b64EncStr = [Base64 encode:encryptedData];
NSLog(@"Base 64 encoded = %@",b64EncStr);
//////////////////// Send this data over network /////////////////////////////////////
// 3) Decode Base 64
// Then you can put that back like this
NSData *b64DecData = [Base64 decode:password1];
// 4) Decrypt
// This should be same before encode -> decode base 64
//NSData *decryptedData = [encryptedData AESDecryptWithPassphrase:password];
NSData *decryptedData = [b64DecData AESDecryptWithPassphrase:password];
NSString* decryptedStr = [[NSString alloc] initWithData:decryptedData encoding:NSASCIIStringEncoding];
NSLog(@"decrypted string = %@",decryptedStr);