50,530
社区成员
发帖
与我相关
我的任务
分享
public static byte[] AESEncrypt(string plainText, string strKey)
{
byte[] cipherBytes2 = new byte[16];
byte[] cipherBytes0 = new byte[32];
byte[] cipherBytes1 = new byte[16];
string strS = plainText.Substring(0, 16);
string strL = plainText.Substring(16, 16);
byte[] inputByteArray = Encoding.UTF8.GetBytes(strS);//得到需要加密的字节数组
byte[] inputByteArray1 = Encoding.UTF8.GetBytes(strL);//得到需要加密的字节数组
byte[] keyBytes = Encoding.UTF8.GetBytes(strKey);
Aes a = new Aes(Aes.KeySize.Bits128, keyBytes);
a.Cipher(inputByteArray, cipherBytes1);
a.Cipher(inputByteArray1, cipherBytes2);
Array.Copy(cipherBytes1, 0, cipherBytes0, 0, cipherBytes1.Length);
Array.Copy(cipherBytes2, 0, cipherBytes0, cipherBytes1.Length,
cipherBytes2.Length);
return cipherBytes0;
}