Otfe/misc/rand/rand.go

21 lines
374 B
Go
Raw Normal View History

2022-02-23 12:07:09 +00:00
package rand
import (
"crypto/rand"
"git.1248.nz/1248/Otfe/misc/b64"
)
//Bytes generates an random set of bytes n long
func Bytes(n int) ([]byte, error) {
b := make([]byte, n)
_, err := rand.Read(b)
return b, err
}
//B64String generates a base 64 string n bytess long
func B64String(n int) (string, error) {
b, err := Bytes(n)
return b64.Encode(string(b)), err
}