switch to go vendoring

This commit is contained in:
Michael Barz
2023-04-19 20:24:34 +02:00
parent 632fa05ef9
commit afc6ed1e41
8527 changed files with 3004916 additions and 2 deletions
+32
View File
@@ -0,0 +1,32 @@
/*
* Copyright 2017 Kopano
*
* Use of this source code is governed by a MIT license
* that can be found in the LICENSE.txt file.
*
*/
package rndm
import (
"crypto/rand"
)
// GenerateRandomBytes returns securely generated random bytes. It will panic
// when the system fails to provide enough secure random data.
func GenerateRandomBytes(n int) []byte {
b := make([]byte, n)
_, err := ReadRandomBytes(b)
if err != nil {
panic("unable to read enough random bytes")
}
return b
}
// ReadRandomBytes is a helper function that reads random data into the provided
// []byte. Tt returns the number of random bytes read and an error if fewer
// bytes were read.
func ReadRandomBytes(b []byte) (n int, err error) {
return rand.Read(b)
}