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.
19 lines
241 B
Go
19 lines
241 B
Go
2 years ago
|
package util
|
||
|
|
||
|
import (
|
||
|
"crypto/rand"
|
||
|
"encoding/base64"
|
||
|
"log"
|
||
|
)
|
||
|
|
||
|
func GenerateRandomString(n int) string {
|
||
|
b := make([]byte, n)
|
||
|
|
||
|
_, err := rand.Read(b)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
return base64.URLEncoding.EncodeToString(b)
|
||
|
}
|