fork download
  1. using System;
  2. using System.Text;
  3. using System.Security.Cryptography;
  4. namespace TestCSharpHMAC
  5. {
  6. public class Program
  7. {
  8. public static void Main(string[] args)
  9. {
  10. string hash = "";
  11. string str = "hogehoge";
  12. //HMAC鍵
  13. string keySource = "qwertyuiopasdfghjklz";
  14. byte[] HmacKey = Encoding.UTF8.GetBytes(keySource);
  15. HMACSHA1 mac = new HMACSHA1(HmacKey);
  16. byte[] hashValue = mac.ComputeHash(Encoding.UTF8.GetBytes(str));
  17. hash = Convert.ToBase64String(hashValue);
  18. Console.WriteLine(hash);
  19. }
  20. }
  21. }
  22.  
Success #stdin #stdout 0.02s 16396KB
stdin
Standard input is empty
stdout
YKJZs5xPTHmotKAw4/tzwciAyis=