v/vlib/crypto/rand/rand.v

28 lines
520 B
V
Raw Normal View History

2020-02-03 05:00:36 +01:00
// Copyright (c) 2019-2020 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
2019-07-31 03:24:12 +02:00
mut arr := []byte
2020-04-10 18:11:43 +02:00
arr = make(len, 1, 1)
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
}