我尝试使用 AES Encrypt 对不同平台的字符串进行加密。我可以成功地执行它 PHP 和 Java。但是当我在 ASP .NET 中尝试它时,它给出了不同的价值。JAVA代码
String input="Text";
String key="1234567891234567";
byte[] crypted = null;
try {
SecretKeySpec skey = new SecretKeySpec(key.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skey);
crypted = cipher.doFinal(input.getBytes());
} catch (Exception exception) {
throw exception;
}
return new String(Base64.encodeBase64(crypted));
ASP 代码:
AesManaged tdes = new AesManaged();
tdes.Key = Encoding.UTF8.GetBytes("1234567891234567");
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform crypt = tdes.CreateEncryptor();
byte[] plain = Encoding.UTF8.GetBytes(Text);
byte[] cipher = crypt.TransformFinalBlock(plain, 0,plain.Length);
encryptedText = Convert.ToBase64String(cipher);
我在第二部分做错了什么?谢谢