I am using this code to encrypt a 8 bytes PlainText with a 8 bytes Key but the result is always a 16 bytes array.
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;
}
The first 8 bytes of the ouptut is what I expect but the rest I don't what it is.. is it something wrong with this code?