【问题标题】:Why does TripleDes use exactly 16 bytes from Rfc2898DeriveBytes?为什么 TripleDes 正好使用来自 Rfc2898DeriveBytes 的 16 个字节?
【发布时间】:2014-08-22 17:56:30
【问题描述】:
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);

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

【问题讨论】:

标签: c# password-encryption tripledes


【解决方案1】:

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

当然,没有什么能阻止您从密钥派生器生成更多字节,但这些算法要么修剪不需要的数据,要么在大小不合法时根本无法工作 - http://msdn.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm.legalkeysizes(v=vs.110).aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-29
    • 2010-11-08
    • 2011-11-29
    相关资源
    最近更新 更多