字符串加密

NSString *password = @"viDveDolleH";
NSString *str = @"Hello World";
NSData *data = [str dataUsingEncoding: NSASCIIStringEncoding];
NSData *encryptedData = [data AESEncryptWithPassphrase:password];	
[Base64 initialize];
NSString *b64EncStr = [Base64 encode:encryptedData];	
NSLog(@"Base 64 encoded = %@", b64EncStr);
    
NSData *b64DecData = [Base64 decode:b64EncStr];
NSData *decryptedData = [b64DecData AESDecryptWithPassphrase:password];	
NSString *decryptedStr = [[NSString alloc] initWithData:decryptedData encoding:NSASCIIStringEncoding];	
NSLog(@"decrypted string = %@", decryptedStr);
 

你可能感兴趣的:(ios,加密,字符串,iPhone)