fork(2) download
  1. using System;
  2. using System.Text;
  3. using System.Security.Cryptography;
  4.  
  5. public class Test
  6. {
  7. public static string getHashSha256(string text)
  8. {
  9. byte[] bytes = Encoding.UTF8.GetBytes(text);
  10. SHA256Managed hashstring = new SHA256Managed();
  11. byte[] hash = hashstring.ComputeHash(bytes);
  12. string hashString = string.Empty;
  13. foreach (byte x in hash)
  14. {
  15. hashString += String.Format("{0:x2}", x);
  16. }
  17. return hashString;
  18. }
  19.  
  20. public static void Main()
  21. {
  22. string str = @"POST
  23. /
  24.  
  25. content-type:application/x-www-form-urlencoded; charset=utf-8
  26. host:iam.amazonaws.com
  27. x-amz-date:20110909T233600Z
  28.  
  29. content-type;host;x-amz-date
  30. b6359072c78d70ebee1e81adcbab4f01bf2c23245fa365ef83fe8f1f955085e2";
  31.  
  32. Console.WriteLine(getHashSha256(str));
  33. Console.WriteLine("Use \\r\\n: {0}", str.Contains("\r\n"));
  34. }
  35. }
Success #stdin #stdout 0.04s 24176KB
stdin
Standard input is empty
stdout
3511de7e95d28ecd39e9513b642aee07e54f4941150d8df8bf94b328ef7e55e2
Use \r\n: False