Skip to content

Instantly share code, notes, and snippets.

@piranha
Created March 11, 2020 12:33
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 piranha/51819b553c95ac36e80c55be3f803f0e to your computer and use it in GitHub Desktop.
Save piranha/51819b553c95ac36e80c55be3f803f0e to your computer and use it in GitHub Desktop.
hex and unhex in clojure
(defn hex [ba]
(->> (map #(format "%02x" %) ba)
(apply str)))
(defn unhex [s]
(->> (partition 2 s)
(map #(Integer/parseInt (apply str %) 16))
byte-array))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment