[英]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. 我收到一个错误。 The error used to be on the key, but its been fixed (I think - unless you spot something wrong).
错误曾经在密钥上,但它已被修复(我认为 - 除非你发现错误)。 However, the error occurs when I set the IV:
但是,当我设置IV时发生错误:
tripledes.IV = pdb.GetBytes(16);
It says that its not a valid initialization vector. 它说它不是一个有效的初始化向量。
How do I fix it? 我如何解决它?
The block size for TripleDES is 64 bits. TripleDES的块大小为64位。 You are trying to set 128 bits.
您正在尝试设置128位。
This should work: 这应该工作:
tripledes.IV = pdb.GetBytes(8);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.