Skip to content

Instantly share code, notes, and snippets.

@brake
Created December 22, 2017 18:21
Show Gist options
  • Save brake/f8193a31c1393953a5b4e7b0e2fe8ee1 to your computer and use it in GitHub Desktop.
Save brake/f8193a31c1393953a5b4e7b0e2fe8ee1 to your computer and use it in GitHub Desktop.
Generate random bytes (hex encoded)
(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