encrypt & decrypt password

swethajain

Well-known member
Joined
Feb 1, 2010
Messages
48
Programming Experience
Beginner
Hi
I have a login page with username & password.I want the password to be encrypted while inserting into the database &decrypted while the user logins and check whether it is valid or not. can anyone give me the source code?

Thanks,
Swetha
 
You don't normally keep password as decryptable data, you use a one-way hash. Each time user enters a password you can hash it and compare with the original. That way there is 'no' way for unauthorized to get that information from your data.
VB.NET:
Dim pass As String = "word"
Dim sha As New System.Security.Cryptography.SHA1Managed
Dim hash As String = Convert.ToBase64String(sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(pass)))
 
Back
Top