Invalid key size creating ICryptoTransform instance for TripleDES

  • Thread starter Thread starter =?iso-8859-1?Q?Jan_Weing=E4rtner?=
  • Start date Start date
?

=?iso-8859-1?Q?Jan_Weing=E4rtner?=

Hi.
I just try to encrypt data with TripleDES.
The LegalKeySize is defined as MinSize=128, MaxSize=192, SkipSize=64.
So i try to use a 128 byte array for key and IV :
-----------------------
byte[] pwd = new System.Text.ASCIIEncoding().GetBytes(new string('a', 128));

byte[] desIV = new System.Text.ASCIIEncoding().GetBytes(new string('b', 128));

System.Security.Cryptography.TripleDESCryptoServiceProvider des3Prov
= new System.Security.Cryptography.TripleDESCryptoServiceProvider();
-----------------------

I get an exception on creating the crypter:
"Specified key is not a valid size for this algorithm."

-----------------------
System.Security.Cryptography.ICryptoTransform crypter
= des3Prov.CreateEncryptor(pwd, desIV);
-----------------------

can anybody help?

thanks and best regards (and a happy new year),
Jan
 
The LegalKeySize is defined as MinSize=128, MaxSize=192, SkipSize=64.
...
byte[] pwd = new System.Text.ASCIIEncoding().GetBytes(new string('a', 128));

How stupid: 128 bit (not byte).

brgds,
Jan
 
Back
Top