rand: extend PRNG interface, add buffering support (#13608)

This commit is contained in:
Subhomoy Haldar 2022-02-28 16:47:54 +05:30 committed by GitHub
parent efeb3e04da
commit a0d9e6e1c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 380 additions and 110 deletions

View file

@ -66,9 +66,8 @@ pub fn ulid_at_millisecond(unix_time_milli u64) string {
return res
}
// read fills in `buf` a maximum of `buf.len` random bytes
pub fn read(mut buf []byte) {
fn read_internal(mut rng PRNG, mut buf []byte) {
for i in 0 .. buf.len {
buf[i] = byte(default_rng.u32())
buf[i] = rng.byte()
}
}