asp.net加密和解密 [英] asp.net encrypt and decript

查看:142
本文介绍了asp.net加密和解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在ASP.NET中解密已经使用MD5格式加密的密码?

How can i decrypt a password that had already encrypted using MD5 format in ASP.NET?

推荐答案

"...使用MD5格式加密的密码. ..":不可能,加密与加密哈希相同. MD5 [ ^ ]是一种哈希算法,它严格地以一种方式工作.哈希值一旦被哈希化,就无法从哈希值中重建出来.

问候,

曼弗雷德

"... encrypted using MD5 format ...": No way, is encryption the same as a chryptographic hash. MD5[^] is a hashing algorithm and it works strictly one way. Once something has been hashed it can not be reconstructed from the hash.

Regards,

Manfred


您永远不需要解密密码.您应该做的是对密码进行哈希处理(如Manfred的回答所述,MD5是哈希算法)并将其存储.要验证密码,请对它进行哈希处理,看看它是否与先前哈希的密码匹配.
You should never need to decrypt a password. What you should do is make a hash of the password (as stated in Manfred''s answer, MD5 is a hashing algorithm) and store that. To verify a password, hash it and see if it matches the previously hashed password.


除了Manfred和lewax00的回答:出于任何安全目的,请勿使用MD5或SHA-1. MD5在2008年被证明是可破解的,在2005年发现了SHA-1缺陷.请参阅:
http://msdn.microsoft. com/en-us/library/system.windows.controls.mediaelement.mediaended%28v = vs.100%29.aspx [ http://en.wikipedia.org/wiki/SHA1 [ http://en.wikipedia.org/wiki/SHA2 [ http://msdn.microsoft.com/en-us/library/system. security.cryptography.hashalgorithm.aspx [ ^ ].

—SA
In addition to the answers by Manfred and lewax00: never use MD5 or SHA-1 for any security purposes. MD5 was proven to be broken in 2008, and SHA-1 flaw was found in 2005. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.mediaended%28v=vs.100%29.aspx[^],
http://en.wikipedia.org/wiki/SHA1[^].

Instead, I would advice using one of the algorithms from the SHA-2 family:
http://en.wikipedia.org/wiki/SHA2[^].

You will find implementation of all those algorithm in .NET:
http://msdn.microsoft.com/en-us/library/system.security.cryptography.hashalgorithm.aspx[^].

—SA


这篇关于asp.net加密和解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆