Friday, October 24, 2008

Encrypting Password to store in Database in C#

Hello Friends,
Many times we face the problem while saving important data to database.This problem can be solve by converting it to encrypted Hash.The program is given below check it out ....



public string Encrypt(string inp)
{
MD5CryptoServiceProvider hasher = new MD5CryptoServiceProvider();
byte[] tBytes = Encoding.ASCII.GetBytes(inp);
byte[] hBytes = hasher.ComputeHash(tBytes);

StringBuilder sb = new StringBuilder();
for (int c = 0; c < hBytes.Length; c++)
sb.AppendFormat("{0:x2}", hBytes[c]);

return (sb.ToString());
}

This is works only for Encryption Decryption is not possible

No comments:

Sign by Rohit Lagu - SUPPORTED BY WE AND COMPUTER