Password Encription c#

While storing the passwords we are requested to store it in an encripted format, so the the direct database viewers will not read the password from the database

See an example
namespace using

using System.Security.Cryptography;

Sample method to encript the password

public string Encript(string password)
System.Security.Cryptography.MD5CryptoServiceProvider objCript =
new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(password);
bs = objCript.ComputeHash(bs);
System.Text.StringBuilder s = new System.Text.StringBuilder();

foreach (byte b in bs)
password = s.ToString();
return password;

Later in the user login time we will again encript the password and will compare it with the encripted password in the database. Thats WE WILL NOT DECRIPT IT.


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: