// 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 string EncodeText(byte[] key, string sText, Encoding encoding) { HMACMD5 hmacMD5 = new HMACMD5(key); byte[] textBytes = encoding.GetBytes(sText); byte[] encodedTextBytes = hmacMD5.ComputeHash(textBytes); string sEncodedText = Convert.ToBase64String(encodedTextBytes); return sEncodedText; } public static void Main(string[] args) { Console.WriteLine(EncodeText(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }, "This is a test!", Encoding.UTF8)); } } }