MD5 password encryption in C#
Password protection is very important for applications that store users’ passwords. One of most secure and commonly used approaches is to only(and only) store the encrypted version of the passwords and not themselves.
The most famous Encryption algorithm is called MD5. Message Digest is a 128bit hash which although has been broken several times, is still serving a lot of applications.
identical strings will result in identical encrypted versions therefore all a developer needs to do is to MD5 the password first time it’s presented to the website. from then on every login the entered password is encrypted and compared against the stored pass.
Here is how you do this in Visual Studio using C#:
1-Importing necessary system parts:
using System.Security.Cryptography; using System.Text;
2-Using the MD5 class
byte pass = Encoding.UTF8.GetBytes(strChange); MD5 md5 = new MD5CryptoServiceProvider(); string encryptedPass = Encoding.UTF8.GetString(md5.ComputeHash(pass));