Skip to content

Instantly share code, notes, and snippets.

@yanfenglee
Created May 19, 2013 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanfenglee/5607924 to your computer and use it in GitHub Desktop.
Save yanfenglee/5607924 to your computer and use it in GitHub Desktop.
(defn get-hash [type data]
(.digest (java.security.MessageDigest/getInstance type) (.getBytes data) ))
(defn sha1-hash [data]
(get-hash "sha1" data))
(defn get-hash-str [data-bytes]
(apply str
(map
#(.substring
(Integer/toString
(+ (bit-and % 0xff) 0x100) 16) 1)
data-bytes)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment