I'm trying to implement this question i asked in the past Securely Encrypt 64bits w/o per element overhead?
In the immediate window i entered TripleDES.Create().LegalBlockSizes.First()
and got
{System.Security.Cryptography.KeySizes}
MaxSize: 64
MinSize: 64
SkipSize: 0
64bits/8bits per byte is 8bytes. Exactly what length a long is. Anyways i run it through the code below and the exception throws. The length of the block is 16bytes. Not what i want to have... I would ask how to change it to 64bits but as the results say the min and max are both 64bits so why am i getting 128bits instead??
long enc(long v, byte[] iv)
{
using (var m = new MemoryStream())
{
using (var c = des.CreateEncryptor(des.Key, iv))
using (var s = new CryptoStream(m, c, CryptoStreamMode.Write))
{
var b = BitConverter.GetBytes(v);
s.Write(b, 0, b.Length);
}
m.Flush();
var arr = m.ToArray();
if(arr.Length!=8)
throw new Exception();
return BitConverter.ToInt64(arr, 0);
}
}