private void HashString(string Text, Grid gAlgorithm) { foreach (UIElement uie in gAlgorithm.Children) { if (uie is RadioButton) { RadioButton rbTemp = (RadioButton)uie; if (rbTemp.IsChecked.Value) { if (rbTemp.Content.ToString().ToLower().Equals("md5")) { tbResultString.Text = Cryptographic.CalculateMD5(System.Text.Encoding.ASCII.GetBytes(Text)); } if (rbTemp.Content.ToString().ToLower().Equals("sha1")) { tbResultString.Text = Cryptographic.CalculateSHA1(System.Text.Encoding.ASCII.GetBytes(Text)); } if (rbTemp.Content.ToString().ToLower().Equals("sha2")) { tbResultString.Text = Cryptographic.CalculateSHA2(System.Text.Encoding.ASCII.GetBytes(Text)); } if (rbTemp.Content.ToString().ToLower().Equals("sha3")) { tbResultString.Text = Cryptographic.CalculateSHA3(System.Text.Encoding.ASCII.GetBytes(Text)); } if (rbTemp.Content.ToString().ToLower().Equals("crc32")) { tbResultString.Text = Cryptographic.CalculateCRC32(System.Text.Encoding.ASCII.GetBytes(Text)); } if (rbTemp.Content.ToString().ToLower().Equals("crc64")) { tbResultString.Text = Cryptographic.CalculateCRC64(System.Text.Encoding.ASCII.GetBytes(Text)); } } } } }
private void HashFile(FileInfoEx file, Grid gAlgorithm) { foreach (UIElement uie in gAlgorithm.Children) { if (uie is RadioButton) { RadioButton rbTemp = (RadioButton)uie; if (rbTemp.IsChecked.Value) { if (rbTemp.Content.ToString().ToLower().Equals("md5")) { file.Hash = new Checksum(algo.MD5, Cryptographic.CalculateMD5(File.ReadAllBytes(file.FullName))); } if (rbTemp.Content.ToString().ToLower().Equals("sha1")) { file.Hash = new Checksum(algo.SHA1, Cryptographic.CalculateSHA1(File.ReadAllBytes(file.FullName))); } if (rbTemp.Content.ToString().ToLower().Equals("sha2")) { file.Hash = new Checksum(algo.SHA2, Cryptographic.CalculateSHA2(File.ReadAllBytes(file.FullName))); } if (rbTemp.Content.ToString().ToLower().Equals("sha3")) { file.Hash = new Checksum(algo.SHA3, Cryptographic.CalculateSHA3(File.ReadAllBytes(file.FullName))); } if (rbTemp.Content.ToString().ToLower().Equals("crc32")) { file.Hash = new Checksum(algo.CRC32, Cryptographic.CalculateCRC32(File.ReadAllBytes(file.FullName))); } if (rbTemp.Content.ToString().ToLower().Equals("crc64")) { file.Hash = new Checksum(algo.CRC64, Cryptographic.CalculateCRC64(File.ReadAllBytes(file.FullName))); } } } } }