// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text; using System.Security.Cryptography; namespace E { public class Program { public static void Main(string[] args) { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); string s1 = "First String Sample"; Console.WriteLine(BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(s1))).Replace("-", "")); string s2 = "Second String Sample"; Console.WriteLine(BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(s2))).Replace("-", "")); string s3 = s1 + s2; Console.WriteLine(BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(s3))).Replace("-", "")); md5.Initialize(); byte[] garbage = new Byte[1000000]; md5.TransformBlock(Encoding.UTF8.GetBytes(s1), 0, Encoding.UTF8.GetByteCount(s1), garbage, 0); md5.TransformFinalBlock(Encoding.UTF8.GetBytes(s2), 0, Encoding.UTF8.GetByteCount(s2)); Console.WriteLine(BitConverter.ToString(md5.Hash).Replace("-", "")); } } }