Расчета контрольной суммы MD5 (хеширование) - C#
Формулировка задачи:
Помогите с процедурой для , ___ где вопросительные знаки нужно вставить процедуру
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
namespace praktic
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string ComputeMD5Checksum(string path)
{
using (FileStream fs = System.IO.File.OpenRead(path))
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] fileData = new byte[fs.Length];
fs.Read(fileData, 0, (int)fs.Length);
byte[] checkSum = md5.ComputeHash(fileData);
string result = BitConverter.ToString(checkSum).Replace("-", String.Empty);
return result;
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
:wall:?????????????????????????????????????????????????
??????????????????????????????????????????
???????????????????????????
???????????????????????:wall:
}
else
{
MessageBox.Show("Не выбран путь к файлу");
}
}
private void button2_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void button1_Click(object sender, EventArgs e)
{
Close();
}
private void button4_Click(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
}
private void button6_Click(object sender, EventArgs e)
{
textBox3.Clear();
textBox4.Clear();
}
}
}Решение задачи: «Расчета контрольной суммы MD5 (хеширование)»
textual
Листинг программы
private string ComputeSHA1Checksum(string path)<br>>>>>> Пустое имя пути не допускается.
{
using (FileStream fs = System.IO.File.OpenRead(path))
{
SHA1 sha1Encrypter = new SHA1CryptoServiceProvider();
byte[] fileData = new byte[fs.Length];
fs.Read(fileData, 0, (int)fs.Length);
byte[] checkSum = sha1Encrypter.ComputeHash(fileData);
string result = BitConverter.ToString(checkSum).Replace("-", "");
return result;
}
}