我怎么能从这个文件中读取md5

时间:2012-03-05 08:45:36

标签: c#

好的,首先,我写信给文件..

string line1, line2, line3, line4, line5, line6, line7, line8, line9, line10;
// step 1, calculate MD5 hash from input
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(Password);
byte[] hash = md5.ComputeHash(inputBytes);

// step 2, convert byte array to hex string
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
    sb.Append(hash[i].ToString("X2"));
}
using (StreamWriter sw = File.CreateText(path))
{
    sw.WriteLine(Username);
    sw.WriteLine(sb.ToString());
}

然后。我怎么能这样才能从文件中读取? 作为普通文本。不是加密表格

1 个答案:

答案 0 :(得分:1)

这里有一个有用的指南:NET-Encryption-Simplified