mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
crypto.rand: update slice method to slice syntax & fix typo in error
This commit is contained in:
parent
05374e162e
commit
8bd17c8016
@ -34,7 +34,7 @@ pub fn read(bytes_needed int) ?[]byte {
|
|||||||
|
|
||||||
fn getrandom(bytes_needed int, buffer voidptr) int {
|
fn getrandom(bytes_needed int, buffer voidptr) int {
|
||||||
if bytes_needed > read_batch_size {
|
if bytes_needed > read_batch_size {
|
||||||
panic('getrandom() dont request more thane $read_batch_size bytes at once.')
|
panic('getrandom() dont request more than $read_batch_size bytes at once.')
|
||||||
}
|
}
|
||||||
return C.syscall(C.SYS_getrandom, buffer, bytes_needed, 0)
|
return C.syscall(C.SYS_getrandom, buffer, bytes_needed, 0)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ fn bytes_to_u64(b []byte) []u64 {
|
|||||||
mut z := [u64(0)].repeat((b.len + ws - 1) / ws)
|
mut z := [u64(0)].repeat((b.len + ws - 1) / ws)
|
||||||
mut i := b.len
|
mut i := b.len
|
||||||
for k := 0; i >= ws; k++ {
|
for k := 0; i >= ws; k++ {
|
||||||
z[k] = binary.big_endian_u64(b.slice(i-ws, i))
|
z[k] = binary.big_endian_u64(b[i-ws..i])
|
||||||
i -= ws
|
i -= ws
|
||||||
}
|
}
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user