我正在使用此代码加密8字节的PlainText,其中包含8字节的密钥,但结果始终是16字节的数组。
public static byte[] Encrypt(byte[] PlainText, byte[] key)
{
MemoryStream ms = new MemoryStream();
DESCryptoServiceProvider mDES = new DESCryptoServiceProvider();
mDES.Mode = CipherMode.ECB;
mDES.Key = key;
CryptoStream encStream = new CryptoStream(ms, mDES.CreateEncryptor(), CryptoStreamMode.Write);
BinaryWriter bw = new BinaryWriter(encStream);
bw.Write(PlainText);
bw.Close();
encStream.Close();
byte[] buffer = ms.ToArray();
ms.Close();
return buffer;
}
ouptut的前8个字节是我所期望的,但其余的我不知道它是什么..这个代码有问题吗?