2019-11-08 06:53:40 +01:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2019-12-04 15:14:04 +01:00
|
|
|
func RandomToken(size int) string {
|
2019-11-08 06:53:40 +01:00
|
|
|
b := make([]byte, size)
|
|
|
|
|
2019-12-04 15:14:04 +01:00
|
|
|
if _, err := rand.Read(b); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2019-11-08 06:53:40 +01:00
|
|
|
|
2019-12-04 15:14:04 +01:00
|
|
|
return fmt.Sprintf("%x", b)
|
2019-11-08 06:53:40 +01:00
|
|
|
}
|