0

hello dear developers.

hi.

i have developed a c# application, it requires a username and a password for login to the application. but the passwords which users provide store in the database in plaintext.
so i want them to be encrypted when stored in database and decrypted when matched at the time of user login.

plz help me in this case.

thx in advance.

bye.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by sknake
0

>so i want them to be encrypted when stored in database and decrypted when matched at the time of user login.

Use classes from System.Security.Cryptography namespace.

MD5 - Message digest example.

string text="samplepassword";
byte  []textByteArray=System.Text.Encoding.UTF8.GetBytes(text);

byte[] computeByteArray = System.Security.Cryptography.MD5.Create().ComputeHash(textByteArray);

//Convert "computerByteArray" into string so we can store into db

string md5Text = Convert.ToBase64String(computeByteArray);

MessageBox.Show(md5Text);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.