目前我这样做:
public static class Crypto
{
public static string Encode(string original)
{
var md5 = new MD5CryptoServiceProvider();
var originalBytes = Encoding.Default.GetBytes(original);
var encodedBytes = md5.ComputeHash(originalBytes);
return BitConverter.ToString(encodedBytes);
}
}
Run Code Online (Sandbox Code Playgroud)
我听说我应该使用一些键来编码.我是不是该?这需要吗?这该怎么做?
您所谈论的内容称为"salt",这是一系列随机数据,您将其附加到原始纯文本字符串.这通常用于密码,防止彩虹表/字典攻击.
阅读:http://en.wikipedia.org/wiki/Salt_%28cryptography%29
对于C#,有一篇很好的文章:http://www.aspheute.com/english/20040105.asp