I am using C# 4.0 Windows Application.I want to give encryption key to protect my file using System.Text.ASCIIEncoding.So, Here my encryption key is SARAVANAN and key length of this is 9.
String enKey="SARAVANAN";
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
des.Key = ASCIIEncoding.ASCII.GetBytes(enKey);
it raised the exception like “Specified key is not a valid size for this algorithm”.But it is working good at length of 8 only.So,i would like to know is there any restriction to this length due to this ASCII ENCODING…
Please guide me get out of this issue?
64 bits is the only valid key size for the DES encryption algorithm.
ASCII encoding uses 8 bits per character, therefore 8 ASCII characters == 64 bits.