16 lines
268 B
Go
16 lines
268 B
Go
|
package toolkit
|
||
|
|
||
|
import (
|
||
|
"crypto/rand"
|
||
|
"encoding/hex"
|
||
|
)
|
||
|
|
||
|
// RandStr returns a random string with the given entropy of bytes.
|
||
|
func RandStr(l int) string {
|
||
|
b := make([]byte, l)
|
||
|
if _, err := rand.Read(b); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
return hex.EncodeToString(b)
|
||
|
}
|