Hi experts,
I have the following code, which works fine:
######################### C# snippet
########################################
string k = "12345678";
string input = "ABCDEFGH";
DES des_dec = new DESCryptoServiceProvider();
byte [] inbuff = ASCIIEncoding.ASCII.GetBytes(input);
byte [] bytesKey = Encoding.ASCII.GetBytes(k);
des_dec.Mode = CipherMode.ECB;
des_dec.Key = bytesKey;
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 ??
Please help.
Thanks to all - greets from germany
Tom