C# 如何从该文件中读取md5

C# 如何从该文件中读取md5,c#,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

好的,首先,我让它写入文件

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、行2、行3、行4、行5、行6、行7、行8、行9、行10;
//步骤1,从输入计算MD5散列
MD5 MD5=System.Security.Cryptography.MD5.Create();
byte[]inputBytes=System.Text.Encoding.ASCII.GetBytes(密码);
byte[]hash=md5.ComputeHash(inputBytes);
//步骤2,将字节数组转换为十六进制字符串
StringBuilder sb=新的StringBuilder();
for(int i=0;i
那么。我怎样才能使它可以从文件中读取?
作为普通文本。不是加密的表单这里有一个有用的指南:

md5是一个不可恢复的散列,这就是重点。不可能将其作为“普通文本”获取。那么,加密密码然后解密或加密文件或其他东西的好方法是什么呢。。我需要一种方法来存储用户和密码,但要加密密码。。或者至少是文件..你不应该解密密码。您应该生成一个散列并像现在这样存储它。当用户登录时,他们将提供他们的密码,然后再次对密码进行散列并比较散列。