Posted By

strelaras on 03/06/13


Tagged

hash SHA1


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

danfinrud55
D4RKCODE


Get a SHA1 hash of a string


 / Published in: C#
 

(example to be enhanced)

  1. public static byte[] GetHash(string inputString)
  2. {
  3. HashAlgorithm algorithm = SHA1.Create(); // SHA1.Create()
  4. return algorithm.ComputeHash(Encoding.UTF8.GetBytes(inputString));
  5. }
  6.  
  7. public static string GetHashString(string inputString)
  8. {
  9. StringBuilder sb = new StringBuilder();
  10. foreach (byte b in GetHash(inputString))
  11. sb.Append(b.ToString("X2"));
  12.  
  13. return sb.ToString();
  14. }

Report this snippet  

You need to login to post a comment.