Skip to content

crypto.rand.internal #

Copyright (c) 2019-2026 Alexander Medvednikov. All rights reserved. Use of this source code is governed by an MIT license that can be found in the LICENSE file.

Constants #

Available on Linux only.

const C.SYS_getrandom int

fn bytes #

fn bytes(bytes_needed int) ![]u8

bytes returns an array filled from the operating system's random source.

fn read #

fn read(mut buffer []u8) !

read fills buffer with random bytes from the OS. Android requires kernel getrandom support (Linux 3.17 or a backport), not the API-28 bionic wrapper. Unavailable or denied syscalls return an error.

fn (ReadError) msg #

fn (err ReadError) msg() string

msg returns the error message.