我试图理解以下代码导致加密字节数组为16字节的原因,如果
plainText
长度为8字节。我期望结果的长度也为8字节?
private static byte[] encrypt(byte[] key, byte[] plainText)
{
try
{
using (MemoryStream ms = new MemoryStream())
{
DES des = new DESCryptoServiceProvider() { Key = key, IV = key };
using (CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write))
{
using(BinaryWriter bw = new BinaryWriter(cs))
{
bw.Write(plainText);
}
}
return ms.ToArray();
}
}
catch (Exception e)
{
Logger.LogWarning(e);
throw e;
}
}