rust-kernel
Rustbelt: a hobby x86_64 kernel written in Rust
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | //! random -- print random bytes from the kernel's entropy source.
//!
//! random 16 random bytes as hex (a fresh 128-bit id)
//! random -n 32 32 bytes as hex
//! random -d 6 [N] roll N dice with 6 sides (default 1 die)
//!
//! The bytes come from the `getrandom` system call (Linux number 318),
//! which the kernel fills from the virtio-rng device, i.e. from the host's
//! /dev/urandom. /dev/random and /dev/urandom read the same source.
use *;
/// Print `n` random bytes as hex digits.
/// A fair number in 1..=sides. Plain `x % sides` would favour small
/// numbers slightly, so throw away the values from the uneven top part.
|