解密会员密码 [英] Decrypt Password in Membership

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

问题描述

我使用Machine Key在会员资格中加密我的密码。我如何解密?



我在web.config中使用此机器密钥







I use Machine Key for Encrypt my Password in membership. How can I decrypt it?

I user this Machine key in web.config



<machinekey>
validationKey="56AB7132992003EE87F74AE4D9675D65EED8018D3528C0B8874905B51940DEAF6B85F1D922D19AB8F69781B2326A2F978A064708822FD8C54ED74CADF8592E17"
decryptionKey="A69D80B92A16DFE1698DFE86D4CED630FA56D7C1661C8D05744449889B88E8DC"
validation="SHA1" decryption="AES"/></machinekey>

推荐答案

你永远不应该让密码可以解密,而应该总是使用密码的哈希。

当用户登录时,你只需要哈希他们的密码,然后比较哈希,但这应该是一个单向的过程,其中解密不会发生。

这个提示很好地说明了如何做到这一点:密码存储:如何操作。 [ ^ ]
You should never make a password decryptable, but rather you should always use a hash of the password.
When a user logs in, you simply hash their password and then compare the hashes, but this should be a one-way process where decryption cannot happen.
This tip shows very well how to do this: Password Storage: How to do it.[^]


HI,



这是一个你可以解决的解决方案e用于解密密码。





Here is a solution that you can use for the decription of password.

/// <summary>
       /// This function is  used for the decription of the password.
       /// </summary>
       /// <param name="stringToDecrypt"></param>
       /// <returns></returns>
        public static string Decrypt(string stringToDecrypt)
        {
            MemoryStream ms = null;
            byte[] inputByteArray = new byte[stringToDecrypt.Length + 1];
            try
            {
                byte[] key = { };
                string sEncryptionKey = "!#


a54?3;
byte [] IV = {18,52,86,120,144,171,205,239};

key = Encoding.UTF8.GetBytes(sEncryptionKey);
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(stringToDecrypt);
ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms,des.CreateDecryptor(key,IV),CryptoStreamMode.Write);
cs.Write(inputByteArray,0,inputByteArray.Length);
cs.FlushFinalBlock();
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
返回encoding.GetString(ms.ToArray());
}
catch(例外e)
{
return e.Message;
}
最后
{
ms = null;
}
}
a54?3"; byte[] IV = { 18, 52, 86, 120, 144, 171, 205, 239 }; key = Encoding.UTF8.GetBytes(sEncryptionKey); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); inputByteArray = Convert.FromBase64String(stringToDecrypt); ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); System.Text.Encoding encoding = System.Text.Encoding.UTF8; return encoding.GetString(ms.ToArray()); } catch (Exception e) { return e.Message; } finally { ms = null; } }







如需使用以下内容:






For encription use the following:

/// <summary>
        /// This function is  used for the encription of the password.
        /// </summary>
        /// <param name="stringToEncrypt">String to encript</param>
        /// <returns></returns>
        public static string Encrypt(string stringToEncrypt)
        {
            MemoryStream ms = null;
            try
            {
                byte[] key = { };
                string sEncryptionKey = "!#


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

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