JanetDocsPlaygroundI'm feeling luckyGitHub sign in

os/cryptorand



    cfunction
    src/core/os.c on line 1286, column 1

    (os/cryptorand n &opt buf)

    Get or append `n` bytes of good quality random data provided by the 
    OS. Returns a new buffer or `buf`.


2 examplesSign in to add an example
Loading...
(let [len 8
      rand-string (string/join (map |(string/format "%02x" $)
                                    (os/cryptorand len)))]
  (= (length rand-string) (* 2 len)))
# => true
sogaiuPlayground
(os/cryptorand 1)  # => @"\n"
(os/cryptorand 1)  # => @"<"
(os/cryptorand 1)  # => @"\xC0"
(os/cryptorand 1)  # => @"\x89"

(os/cryptorand 8)  # => @"\x87\x13\x99\x95\x10su\e"
cellularmitosisPlayground