MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des_dec.CreateEncryptor(),
CryptoStreamMode.Write);
cs.Write(inbuff, 0, inbuff.Length);
cs.Close();
byte [] encryptedData = ms.ToArray();
######################### end C# snippet
####################################
After executing the snippet, the byte array encryptedData contains 16
Bytes - although I just gave 8 bytes with inbuff. WHY ????
I am working on a class to communicate with an external device, which
en- and decrypts data using DES ECB standard (the simplest one).
The problem is: Encrypting by the same key and standards like showed
in the code snippet just generates an 8 byte encrypted array. This
result (generated by firmware of device which is programmed in ANSI-C)
can not be decrypted using the DESCryptoServiceProvider, it always
returns an exception with the meassage "Invalid Data".
Is there anything I did wrong ? Why does DESCryptoServiceProvider
generate a 16 byte array out of a 8 byte array input ??
this solved my problem - thank you very much for your help !!
Regards
Thomas
gary@computa.co.uk (Gary Short) wrote in message news:<1710107e.0503030233.ad062f2@posting.google.c om>...[color=blue]
> Hello Tom,
>
> The extra 8 bytes are basically padding. Use the line,
>
> des_dec.Padding = PaddingMode.None
>
> to fix the problem, though realise that this is very insecure.
>
> HTH,
> Gary Short[/color]