加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

ASP.Net机器密钥,验证密钥和解密密钥 – 密钥长度

发布时间:2020-12-16 03:56:21 所属栏目:asp.Net 来源:网络整理
导读:将ValidationKey和DecryptionKey保留为默认值时生成的默认密钥长度是多少?例如: machineKey decryptionKey="AutoGenerate,IsolateApps" validationKey="AutoGenerate,IsolateApps" ... / 我无法在MSDN上的任何地方找到此文档. 我想生成一个静态机器密钥并
将ValidationKey和DecryptionKey保留为默认值时生成的默认密钥长度是多少?例如:

<machineKey decryptionKey="AutoGenerate,IsolateApps" validationKey="AutoGenerate,IsolateApps" ... />

我无法在MSDN上的任何地方找到此文档.
我想生成一个静态机器密钥并使其与默认值保持一致.

解决方法

这个 MSDN页面讨论了machineKey web.config元素:

“For SHA1,set the validationKey to 64 bytes (128 hexadecimal characters).
For AES,set the decryptionKey to 32 bytes (64 hexadecimal characters).
For 3DES,set the decryptionKey to 24 bytes (48 hexadecimal characters).”

另一个MSDN页面有其他信息:

“validationKey specifies a manually
assigned validation key. This value
must be manually set to ensure
consistent configuration across a
network of Web servers (a Web farm).
The key must be a minimum of 40
characters (20 bytes) and a maximum of
128 characters (64 bytes) long. If
keys shorter than the maximum length
are used,they should be created by a
truly random means,such as by using
RNGCryptoServiceProvider. The
recommended key length is 128
hexadecimal characters. If you add the
IsolateApps modifier to the
validationKey value,ASP.NET generates
a unique encrypted key for each
application using each application’s
application ID.”

“decryptionKey specifies a manually assigned key. This value must be manually set to a string of hexadecimal characters to ensure consistent configuration across a Web farm. The key should be 16 characters in length when using DES encryption and 48 characters in length when using Triple DES encryption. If keys shorter than the maximum length are used,they should be created by a truly random means,such as by using RNGCryptoServiceProvider. ASP.NET can use Triple DES only on computers on which 128-bit encryption is available. If you add the IsolateApps modifier to the decryptionKey value,ASP.NET generates a unique encrypted key for each application using each application’s application ID.”

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读