Created
July 6, 2010 12:20
-
-
Save dsp/465314 to your computer and use it in GitHub Desktop.
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
(ns | |
#^{:doc "Utilities"} | |
gh.util | |
(:import java.security.MessageDigest)) | |
(defn digest | |
"Calculates a digest with the given algorithm" | |
([str] (digest str "SHA1")) | |
([str dig] | |
(apply vector (.digest (MessageDigest/getInstance dig) (.getBytes str))))) | |
(defn vec-to-str | |
"Converts a vector to a string representation" | |
[vec] | |
(apply str (map #(format "%02x" (bit-and 0xff %)) vec))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment