Last active
January 21, 2023 15:03
-
-
Save sogaiu/fa930abb815daade41dd24e0c76f4d86 to your computer and use it in GitHub Desktop.
cross-platform sha1 for babashka
This file contains hidden or 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
;; adapted borkdude's implementation | |
(defn sha1 | |
[s] | |
(let [hashed (.digest (.getInstance java.security.MessageDigest "SHA-1") | |
(.getBytes s)) | |
sw (java.io.StringWriter.)] | |
(binding [*out* sw] | |
(doseq [byte hashed] | |
(print (format "%02x" byte)))) ; prefer lower case :) | |
(str sw))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment