Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
}


What I have tried:

i have a Encrypt Password method need decrypt password method in c#.. Tried a lot need help
Posted
Updated 17-May-17 18:55pm
Comments
PIEBALDconsult 17-May-17 23:22pm    
Why?

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[^]
 
Share this answer
 
Quote:
i have a Encrypt Password method need decrypt password method in c#

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900