Update: Stronger password encryption
Yesterday, I wrote how to encrypt a password using a one-way MD5 hash, but as some of the comments point out, the MD5 algorithm is not strong enough. I listened and wrote a new encryption method that uses SHA256 instead of MD5.
public string Encrypt(string plainMessage)
{
byte[]
data = Encoding.UTF8.GetBytes(plainMessage);
using (HashAlgorithm sha
= new SHA256Managed())
{
byte[]
encryptedBytes = sha.TransformFinalBlock(data, 0, data.Length);
return Convert.ToBase64String(sha.Hash);
}
}
If I pass my own name to the Encrypt method this would be the result:
Encrypt("
Comments
Comments are closed