加密-机器密钥
我正在尝试找出一种安全的方法,使用 C# 为我的网络应用程序加密数据库中的几个字段。
我需要找到一个执行加密/解密的脚本以及存储密钥的方法。我读到您可以使用 machinekey 作为密钥,这是正确的吗?
有自动生成和非自动生成的机器密钥。我想我宁愿选择非自动生成的,因为这样可以很容易地将我的网络应用程序部署到不同的服务器中。我发现这个工具可以为您生成一个:
http://aspnetresources.com/tools/machineKey
什么加密/解密脚本可以与此机器密钥配合使用?
我还想知道,将非自动生成的机器密钥存储在 web.config 文件中有多安全?如果有人可以看到 web.config 文件,为什么要使用 machinekey 而不是 appSettings 中的“普通”密钥?
I'm trying to figure out a secure way of encrypting a couple of fields in my database using C# for my web app.
I need to find a script that does the encryption/decryption and a way of storing the key. I read that you can use the machinekey as a key, is that correct?
There are autogenerated and non-autogenerated machinekeys. I think I would rather go with the non-autogenerated, as this way it will be easy to deploy my web app into different servers. I found this tool where it generates one for you:
http://aspnetresources.com/tools/machineKey
What encryption/decryption script would work with this machinekey?
Also I was wondering, how secure is it to store the non-autogenerated machine key in the web.config file? If someone can see the web.config file, why use machinekey instead of a "normal" key in appSettings for instance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据该文章,生成了 256 位解密密钥和 512 位验证密钥,它们与 Rijndael 算法相匹配,因此您需要它的 C# 实现,该实现已位于 System.Security.Cryptography 中/代码> 命名空间。
这里有两个函数可以完成这项工作:
和 :
关于你的第二个问题,生成的机器密钥是一个十六进制字符串,它是人类可读的,但你无法弄清楚。
我希望这有帮助。
According to that article, a 256-bit decryption key and a 512-bit validation key are generated and they go with the Rijndael algorithm, so you need a C# implementation of it which is already in the
System.Security.Cryptography
namespace.Here is two functions that do the work:
And :
And about your second question, the generated machinekey is a hexadecimal string which is human readable but you cannot figure it out.
I hope this help.