我有一个加密密码方法需要在c#中解密密码方法。 [英] I have a encrypt password method need decrypt passwordmethod in c#..

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

问题描述

protected System.Text.StringBuilder EncriptPassword(string Password)
{
    //Define String Builder
    System.Text.StringBuilder Encvalue = new System.Text.StringBuilder();
    System.Security.Cryptography.MD5CryptoServiceProvider crypto = new System.Security.Cryptography.MD5CryptoServiceProvider();
    //Change password into Bytes
    byte[] bs = System.Text.Encoding.UTF8.GetBytes(Password);
    bs = crypto.ComputeHash(bs);

    foreach (byte b in bs)
    {
        //append into String Builder with hexadecimal format
        Encvalue.Append(b.ToString("x2").ToLower());
    }

    return Encvalue;
}





我尝试过:



i有一个加密密码方法需要在c#中解密密码方法。试过很多需要帮助



What I have tried:

i have a Encrypt Password method need decrypt password method in c#.. Tried a lot need help

推荐答案

你正在加密 (真正散列)使用MD5的密码。因为它正在被哈希,你不能/不解密它,你只需要比较你的哈希来决定用户是否经过身份验证。



如果你是想要解密密码是一种简单的方法来解决我忘了密码你最好在应用程序中实现该功能,以防你的系统遭到入侵并且所有用户密码都被上传到互联网。



但要具体回答这个问题,你需要使用加密算法(例如:blowfish)而不是哈希算法。以河豚为例。



Google [ ^ ]



GitHub - b1thunt3r / blowfish-csharp:C#的Blowfish加密库 [ ^ ]



Blowfish C#和C ++源代码 - 清除安全性 [ ^ ]



Koders代码搜索:Blowfish.cs - C# - GPL [ ^ ]
You are "encrypting" (really hashing) your passwords using MD5. Because it is being hashed you can't/don't decrypt it, you merely compare your hashes to decide if the user is authenticated or not.

If you are wanting to decrypt the password as a easy way to remedy "i forgot my password" you are better off implementing that functionality as part of your App in case your system is compromised and all your users passwords are uploaded to the internets.

But to answer the question specifically, you need to use an encryption algorithm (ex: blowfish) and not a hashing algorithm. Take a look at blowfish for example.

Google[^]

GitHub - b1thunt3r/blowfish-csharp: Blowfish encrytion library for C#[^]

Blowfish C# and C++ Source Code - Defuse Security[^]

Koders Code Search: Blowfish.cs - C# - GPL[^]


引用:

i有一个加密密码方法需要c#中的解密密码方法

i have a Encrypt Password method need decrypt password method in c#



没有解密的可能性,因为 MD5不加密,它是散列的。

哈希是一个单向的过程,无法逆转。



MD5 - 维基百科 [ ^ ]

哈希函数 - 维基百科 [ ^ ]


There is no decryption possibility because MD5 is not encryption, it is hashing.
Hashing is a one way process and can't be reversed.

MD5 - Wikipedia[^]
Hash function - Wikipedia[^]


这篇关于我有一个加密密码方法需要在c#中解密密码方法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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