fork(142) download
  1. using System;
  2. using System.Text;
  3. using System.Security.Cryptography;
  4.  
  5. public class Program
  6. {
  7. private const string key = "key";
  8. private const string message = "message";
  9. private static readonly Encoding encoding = Encoding.UTF8;
  10.  
  11. static void Main(string[] args)
  12. {
  13. var keyByte = encoding.GetBytes(key);
  14. using (var hmacsha256 = new HMACSHA256(keyByte))
  15. {
  16. hmacsha256.ComputeHash(encoding.GetBytes(message));
  17.  
  18. Console.WriteLine("Result: {0}", ByteToString(hmacsha256.Hash));
  19. }
  20. }
  21. static string ByteToString(byte[] buff)
  22. {
  23. string sbinary = "";
  24. for (int i = 0; i < buff.Length; i++)
  25. sbinary += buff[i].ToString("X2"); /* hex format */
  26. return sbinary;
  27. }
  28. }
  29.  
Success #stdin #stdout 0.07s 34232KB
stdin
Standard input is empty
stdout
Result: 6E9EF29B75FFFC5B7ABAE527D58FDADB2FE42E7219011976917343065F58ED4A