Home > .NET > MD5 password encryption in C#

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));
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: