Inital commit
This commit is contained in:
20
misc/rand/rand.go
Normal file
20
misc/rand/rand.go
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user