Created
February 15, 2011 08:36
-
-
Save prasincs/827272 to your computer and use it in GitHub Desktop.
clojure sha1 hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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