TripleDES IV for C #?

So when I say something like:

TripleDES tripledes = TripleDES.Create(); Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(password, plain); tripledes.Key = pdb.GetBytes(16); tripledes.IV = pdb.GetBytes(16); 

I get an error message. The error was on the key, but it was fixed (I think - if you did not notice something was wrong). However, an error occurs when I set the value to IV:

 tripledes.IV = pdb.GetBytes(16); 

It says that its invalid initialization vector.

How to fix it?

+4
source share
1 answer

The block size for TripleDES is 64 bits. You are trying to set 128 bits.

This should work:

 tripledes.IV = pdb.GetBytes(8); 
+7
source

All Articles