예제 #1
0
        private void Crc32Menu_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog {
                Filter = "All Files|*.*"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var data       = File.ReadAllBytes(dialog.FileName);
                var hash       = Crc32.CalculateCrc(data);
                var bytes      = BitConverter.GetBytes(hash);
                var hashString = BitConverter.ToString(bytes);
                CopyMessageBox.Show("CRC32:", hash.ToString(), "Calculated CRC32");
            }
        }
예제 #2
0
        private void Md5Menu_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog {
                Filter = "All Files|*.*"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var data = File.ReadAllBytes(dialog.FileName);

                byte[] hash;

                using (var md5 = MD5.Create())
                {
                    hash = md5.ComputeHash(data);
                }

                var hashString = BitConverter.ToString(hash);
                CopyMessageBox.Show("MD5:", hashString, "Calculated MD5");
            }
        }