的iOS:
我使用NSString + AESCrypt(https://github.com/Gurpartap/AESCrypt-ObjC)
樣品:
NSString* encrypted = [plainText AES256EncryptWithKey:@"MyEncryptionKey"];
NSString* decrypted = [encrypted AES256DecryptWithKey:@"MyEncryptionKey"];
的Android(AES256Cipher - https://gist.github.com/dealforest/1949873):
加密:
String base64Text="";
try {
String key = "MyEncryptionKey";
byte[] keyBytes = key.getBytes("UTF-8");
byte[] ivBytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte[] cipherData;
//############## Request(crypt) ##############
cipherData = AES256Cipher.encrypt(ivBytes, keyBytes, passval1.getBytes("UTF-8"));
base64Text = Base64.encodeToString(cipherData, Base64.DEFAULT);
}
catch (Exception e) {
e.printStackTrace();
}
解密:
String base64Text="";
String plainText="";
try {
String key = "MyEncryptionKey";
byte[] keyBytes = key.getBytes("UTF-8");
byte[] ivBytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte[] cipherData;
//############## Response(decrypt) ##############
base64Text = User.__currentUser.getPasscode();
cipherData = AES256Cipher.decrypt(ivBytes, keyBytes, Base64.decode(base64Text.getBytes("UTF-8"), Base64.DEFAULT));
plainText = new String(cipherData, "UTF-8");
}
catch (Exception e)
{
e.printStackTrace();
}
「那不行」,不僅是文字上不正確,這是一個可怕的描述以及。在客戶端嘗試做什麼?你是如何傳輸密文的? –