Encrypt Error

S

SJ

Hello,

I'm trying to use Cryptography to encrypt/decrypt data in my application.
It was working just fine on my old computer, but now I've switched machines,
and I get the following error at Runtime.


ICryptoTransform transform = des.CreateEncryptor(desKey, desIV);
[CryptographicException: Specified initialization vector (IV) does not match
the block size for this algorithm.]

System.Security.Cryptography.TripleDESCryptoServiceProvider._NewEncryptor(By
te[] rgbKey, CipherMode mode, Byte[] rgbIV, Int32 feedbackSize,
CryptoAPITransformMode encryptMode) +1350544

System.Security.Cryptography.TripleDESCryptoServiceProvider.CreateEncryptor(
Byte[] rgbKey, Byte[] rgbIV) +41
glib.Crypto.EncryptData(Byte[] desKey, Byte[] desIV, String data) in
c:\blah\blah\blah\blah.cs:74


I'm using this to generate the key and IV Vector. :
byte[] key =
System.Text.ASCIIEncoding.ASCII.GetBytes("abcdefghijklm123xxxxxxxx");
//Using the same value for the IV


Thanks.
 
G

Guest

SJ,

I had the sam issue. The IV must be 8 bytes, but the key can be 24 bytes.
If you check the property des3.LegalBlockSizes[0], the min max value is 64.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top