Created
December 22, 2017 18:21
-
-
Save brake/f8193a31c1393953a5b4e7b0e2fe8ee1 to your computer and use it in GitHub Desktop.
Generate random bytes (hex encoded)
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
(import [javax.xml.bind DatatypeConverter]) | |
(defn random-bytes-hex | |
[n] | |
(->> (repeatedly n (fn [] (rand-int 255))) | |
(map unchecked-byte) | |
byte-array | |
(DatatypeConverter/printHexBinary))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment