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)
{
s.Append(b.ToString("x2").ToLower());
}
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.