I can't figure out how to use the MD5 clases in System.Security.Cryptography. I'm trying to write a app that will get the MD5 sum of a file. There are more components to this app than just what you see, I can't figure out how to do this.
Box that should output the MD5 sum is: md5Box.Text
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Stream fileOpen;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = @"C:\";
openFileDialog1.Filter = "All Files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((fileOpen = openFileDialog1.OpenFile()) != null)
{
HashAlgorithm e = new MD5CryptoServiceProvider();
e.ComputeHash(fileOpen);
/* STUCK HERE */
}
}
}
}
Question
Ultra Frosty
I can't figure out how to use the MD5 clases in System.Security.Cryptography. I'm trying to write a app that will get the MD5 sum of a file. There are more components to this app than just what you see, I can't figure out how to do this.
Box that should output the MD5 sum is: md5Box.Text
Link to comment
Share on other sites
4 answers to this question
Recommended Posts