Professional Documents
Culture Documents
Mã Hóa md5
Mã Hóa md5
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
namespace Md5APP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Lu lt qu
String ext = Path.GetExtension(tbHienThi.Text);
SaveFileDialog sd = new SaveFileDialog();
sd.Filter = "MD5 file(*.md5)|*.md5";
if (rbMaHoa.Checked)
{
if (sd.ShowDialog() == DialogResult.OK)
{
String ext2 = Path.GetExtension(sd.FileName);
String fileName = sd.FileName.Substring(0,
sd.FileName.IndexOf('.'));
String fullName = fileName + ext + ext2;
FileStream fss = new FileStream(fullName, FileMode.CreateNew);
fss.Write(ketQuaMaHoa, 0, ketQuaMaHoa.Length);
fss.Close();
tbHienThi.Text = "";
tbMatKhau.Text = "";
}
}
else
{
String oldExt = tbHienThi.Text.Substring(tbHienThi.Text.IndexOf('.'),
tbHienThi.Text.LastIndexOf('.') - tbHienThi.Text.IndexOf('.'));
sd.Filter = "(*" + oldExt + ")|*" + oldExt;
if (sd.ShowDialog() == DialogResult.OK)
{
FileStream fss = new FileStream(sd.FileName, FileMode.CreateNew);
fss.Write(ketQuaMaHoa, 0, ketQuaMaHoa.Length);
fss.Close();
tbHienThi.Text = "";
tbMatKhau.Text = "";
}
}
}
catch
{
MessageBox.Show("Sai mt khu");
tbMatKhau.Text = "";
return;
}
}
}
}
}