top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to Encode and Decode Password in Asp.net Registration and Login Page using C#?

0 votes
119 views
How to Encode and Decode Password in Asp.net Registration and Login Page using C#?
posted Apr 27, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
 
Best answer

You can ecrypt the password as given below:

   private string Encrypt_Password(string password)
    {
        string pwdstring = string.Empty;
        byte[] pwd_encode = new byte[password.Length];
        pwd_encode = Encoding.UTF8.GetBytes(password);
        pwdstring = Convert.ToBase64String(pwd_encode);
        return pwdstring;
    }  

Decode Password:

 private string Decrypt_Password(string encryptpassword)
    {
        string pwdstring = string.Empty;
        UTF8Encoding encode_pwd = new UTF8Encoding();
        Decoder Decode = encode_pwd.GetDecoder();
        byte[] todecode_byte = Convert.FromBase64String(encryptpassword);
        int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
        char[] decoded_char = new char[charCount];
        Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
        pwdstring = new String(decoded_char);
        return pwdstring;
    }
answer May 3, 2017 by Shweta Singh
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...