.NET 4.x Как подсчитать MD5 для каждой строки файла? - C#
Формулировка задачи:
string[] lines = File.ReadAllLines(@"C:/Users/Addff/Desktop/text.txt");
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
Byte[] bytes4MD5 = Encoding.UTF8.GetBytes(lines);
byte[] checkSum = md5.ComputeHash(bytes4MD5);
string result = BitConverter.ToString(checkSum).Replace("-", String.Empty);
File.WriteAllLines(@"C:/Users/Addff/Desktop/text.txt"),result.ToLower());Решение задачи: «.NET 4.x Как подсчитать MD5 для каждой строки файла?»
textual
Листинг программы
string[] lines = File.ReadAllLines("C:/Users/Addff/Desktop/text.txt");
var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
for (int i=0; i<lines.Length; i++)
{
byte[] bytes4MD5 = Encoding.UTF8.GetBytes(lines[i]);
byte[] checkSum = md5.ComputeHash(bytes4MD5);
string result = BitConverter.ToString(checkSum).Replace("-", "").ToLower();
lines[i] += " " + result;
}
File.WriteAllLines("C:/Users/Addff/Desktop/text.txt", lines);