Guest User

Untitled

a guest
May 2nd, 2012
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. /* CUT */
  2.  
  3.  
  4. #define SHABUFLEN (SHA1_DIGEST_LENGTH * 2)
  5.  
  6. char *sha1_hash(const char *s, size_t size) {
  7.  
  8. static char shabuf[SHABUFLEN + 1];
  9. unsigned char digestbuf[SHA1_DIGEST_LENGTH];
  10. int i;
  11. SHA1_CTX digest;
  12.  
  13. SHA1Init(&digest);
  14.  
  15. SHA1Update(&digest, (unsigned char *) s, size);
  16. SHA1Update(&digest, (unsigned char *) cloak_key, cloak_key_len);
  17.  
  18. SHA1Final(digestbuf, &digest);
  19.  
  20. for (i = 0; i < SHA1_DIGEST_LENGTH; i++)
  21. snprintf(shabuf+2*i, sizeof(shabuf) - 2*i, "%02x", digest[i]);
  22. shabuf[SHABUFLEN] = '\0';
  23.  
  24. return shabuf;
  25. }
  26.  
  27. /* CUT */
Advertisement
Add Comment
Please, Sign In to add comment