I would like to know how to decrypt some text encrypted on iPhone using AES256 and PKCS7Padding with a PHP function.
I use following Objective-C code.
https://gist.github.com/838614
- (NSString *)AES256EncryptWithKey:(NSString *)key
{
NSData *plainData = [self dataUsingEncoding:NSUTF8StringEncoding开发者_开发知识库];
NSData *encryptedData = [plainData AES256EncryptWithKey:key];
NSString *encryptedString = [encryptedData base64Encoding];
return encryptedString;
}
The following PHP snippet covers removing PKCS7 padding, which combined with this SO question (but substituting MCRYPT_RIJNDAEL_128
for MCRYPT_RIJNDAEL_256
in your case) should give you what you need.
精彩评论