Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active January 21, 2023 15:03
Show Gist options
  • Save sogaiu/fa930abb815daade41dd24e0c76f4d86 to your computer and use it in GitHub Desktop.
Save sogaiu/fa930abb815daade41dd24e0c76f4d86 to your computer and use it in GitHub Desktop.
cross-platform sha1 for babashka
;; 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