v/vlib/crypto/rand/rand.v

27 lines
513 B
V
Raw Normal View History

2020-02-03 04:00:36 +00:00
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
2019-07-31 01:24:12 +00:00
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module rand
const (
2019-10-29 16:59:55 +00:00
read_error = error('crypto.rand.read() error reading random bytes')
2019-07-31 01:24:12 +00:00
)
// NOTE: temp until we have []bytes(buff)
2020-04-14 19:03:02 +00:00
fn c_array_to_bytes_tmp(len int, buffer voidptr) []byte {
2020-04-10 16:11:43 +00:00
mut arr := []byte{len:len, cap:1}
2020-04-10 16:11:43 +00:00
arr.data = buffer
/*
2019-07-31 01:24:12 +00:00
arr = array {
len: len
cap: 1
element_size: 1
data: buffer
}
2020-04-10 16:11:43 +00:00
*/
2019-07-31 01:24:12 +00:00
return arr
}