RNCryptor/JNCryptor-在android中加密的ios中解密字符串



Hellp All,

我在iOS和android中使用了RNCryptor/JNCryptor。以下是在android中加密和在iOS中解密的代码。

在安卓中加密代码

public static String EncryptMessage(String message)
{
JNCryptor cryptor = new AES256JNCryptor();
byte[] plaintext = message.getBytes();
byte[] ciphertext = null;
try {
ciphertext = cryptor.encryptData(plaintext,Constants.ENCRYPTION_KEY.toCharArray());
} catch (CryptorException e) {
// Something went wrong
e.printStackTrace();
}
return  Base64.encodeBytes(ciphertext);
}

在iOS 中解密代码

 NSData *fromAData =     [@"AwEche05IIj/OYEN5brgF/p6jyfKfARJliUQwEwa2lko40+ScPMumlDSIZWB2O6XRZjIucXVbggieWaHb2x6sJkYYt7tn3k17V5Jd5PAnkIoFA==" base64DecodedData];
NSData *fromADecryptedData = [RNDecryptor decryptData:fromAData withSettings:kRNCryptorAES256Settings password:@"password" error:&decryptionError];
NSLog(@"decryptionError %@", decryptionError);
NSLog(@"Result = %@", fromPHPDecryptedData);
NSLog(@"Result = %@", [[NSString alloc] initWithData:fromADecryptedData encoding:NSUTF8StringEncoding]);

我也尝试过简单的密码解密

 NSData *fromADecryptedData = [RNDecryptor decryptData:fromAData withPassword:@"password" error:&decryptionError];

获取未知标头的错误,错误代码=2

我在两侧使用相同的刺痛"密码"作为密码。

如果有人有任何想法,如果我遗漏了什么,请告诉我。

当我在iOS中更新了我的RNcryptor库时,它就工作了。。。

我的iOS RNcryptor库版本是v2.2

Android版本1.2.0

最新更新