我有以下用java编写的代码。我需要 C# 等效项。
Key key = new SecretKeySpec(keyValue, "AES");
Cipher c = Cipher.getInstance("AES");
c.init(1, key);
byte[] encVal = c.doFinal(Data.getBytes());
encryptedValue = new BASE64Encoder().encode(encVal);
这里的 C# 代码相当于 java 中的代码。
System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();
AesManaged tdes = new AesManaged();
tdes.Key = UTF8.GetBytes(keyValue);
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);
String encryptedText = Convert.ToBase64String(cipher);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)