Created
March 11, 2020 12:33
-
-
Save piranha/51819b553c95ac36e80c55be3f803f0e to your computer and use it in GitHub Desktop.
hex and unhex in clojure
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
(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