Pages

Wednesday, June 1, 2011

MD5 Hash Encript (C#)

using System.Security.Cryptography;
private string MD5Encrypt(string plaintext)
    {
        ciphertext = "";
        MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
        byte[] data = System.Text.Encoding.ASCII.GetBytes(plaintext);
        data = md5Hasher.ComputeHash(data);
        for (int i = 0; i < data.Length; i++)
        {
            ciphertext += data[i].ToString("x2").ToLower();
        }
        return ciphertext;
}

No comments:

Post a Comment

ShareThis