I'm trying to understand why the following code results in the encrypted byte array being 16 bytes if plainText
is 8 bytes in length. I expected the result to also be 8 bytes in length?
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;
}
}