v/vlib/crypto/rand/rand.v

27 lines
513 B
V
Raw Normal View History

// Copyright (c) 2019-2021 Alexander Medvednikov. All rights reserved.
2019-07-31 03:24:12 +02: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 17:59:55 +01:00
read_error = error('crypto.rand.read() error reading random bytes')
2019-07-31 03:24:12 +02:00
)
// NOTE: temp until we have []bytes(buff)
2020-04-14 21:03:02 +02:00
fn c_array_to_bytes_tmp(len int, buffer voidptr) []byte {
2020-04-10 18:11:43 +02:00
mut arr := []byte{len:len, cap:1}
2020-04-10 18:11:43 +02:00
arr.data = buffer
/*
2019-07-31 03:24:12 +02:00
arr = array {
len: len
cap: 1
element_size: 1
data: buffer
}
2020-04-10 18:11:43 +02:00
*/
2019-07-31 03:24:12 +02:00
return arr
}