Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么三元组使用Rfc2898DeriveBytes中的16个字节?_C#_Password Encryption_Tripledes - Fatal编程技术网

C# 为什么三元组使用Rfc2898DeriveBytes中的16个字节?

C# 为什么三元组使用Rfc2898DeriveBytes中的16个字节?,c#,password-encryption,tripledes,C#,Password Encryption,Tripledes,我的问题是为什么是.GetByte 16?RijndaelManaged也一样吗?它需要16个字节?这是因为算法所需密钥的大小: 根据模式,三元组需要128(16字节)或196 比特- Rhindael需要128或256位- 当然,没有什么可以阻止您从密钥派生程序生成更多字节,但这些算法要么会修剪不需要的数据,要么在大小不合法的情况下完全无法工作。看起来16只是您希望该方法返回的伪随机密钥字节数。 Rfc2898DeriveBytes k1 = new Rfc2898DeriveByte

我的问题是为什么是.GetByte 16?RijndaelManaged也一样吗?它需要16个字节?

这是因为算法所需密钥的大小:

  • 根据模式,三元组需要128(16字节)或196 比特-
  • Rhindael需要128或256位-

当然,没有什么可以阻止您从密钥派生程序生成更多字节,但这些算法要么会修剪不需要的数据,要么在大小不合法的情况下完全无法工作。

看起来16只是您希望该方法返回的伪随机密钥字节数。
Rfc2898DeriveBytes k1 = new Rfc2898DeriveBytes(pwd1, salt1, myIterations);

Rfc2898DeriveBytes k2 = new Rfc2898DeriveBytes(pwd1, salt1);

// Encrypt the data.
TripleDES encAlg = TripleDES.Create();
encAlg.Key = k1.GetBytes(16);