Skip to content

Instantly share code, notes, and snippets.

@mpenet
Last active December 16, 2015 01:49
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 mpenet/5358210 to your computer and use it in GitHub Desktop.
Save mpenet/5358210 to your computer and use it in GitHub Desktop.
(defn x->sha1
[x]
(->> (.getBytes (pr-str x))
(.digest (java.security.MessageDigest/getInstance "SHA1"))
(#(apply str (map (fn [i] (format "%02x" (bit-and i 0xff))) %)))))
(prn (x->sha1 {:a 2}))
"0be74d5e229441849c6c1e4a5e4b80c4c7b84312"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment