Skip to content

Instantly share code, notes, and snippets.

@tggreene
Created May 4, 2020 18:57
Show Gist options
  • Save tggreene/699185df598a6a41b886460cfa4e34c6 to your computer and use it in GitHub Desktop.
Save tggreene/699185df598a6a41b886460cfa4e34c6 to your computer and use it in GitHub Desktop.
Get random bytes in clojure
(defn urandom
[n]
(with-open [in (io/input-stream (io/file "/dev/urandom"))]
(let [buf (byte-array n)
_ (.read in buf)]
buf)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment