1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

crypto: implement rand.bytes(needed_bytes int) ?[]byte, use it consistently instead of the old rand.read(), which will change to be compatible with io and the pseudo random rand module

This commit is contained in:
Delyan Angelov
2022-02-15 18:39:17 +02:00
parent 80444c8ec4
commit ff34b79d39
4 changed files with 12 additions and 2 deletions

View File

@ -0,0 +1,15 @@
import crypto.rand
fn test_reading() ? {
a := rand.read(32) ?
// dump(a.hex())
assert a.len == 32
mut histogram := [256]int{}
for b in a {
histogram[b]++
}
// dump(histogram)
for h in histogram {
assert h < 10
}
}