You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
286 B
Go

package util
import (
"crypto/rand"
"encoding/base64"
)
// RandomHash generates a random cryptograph base64 string of the given length.
func RandomHash(len int) string {
buff := make([]byte, len)
rand.Read(buff)
str := base64.StdEncoding.EncodeToString(buff)
return str[:len]
}