15 lines
180 B
Go
15 lines
180 B
Go
|
package util
|
||
|
|
||
|
import (
|
||
|
"crypto/rand"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
func RandomToken(size int) (string, error) {
|
||
|
b := make([]byte, size)
|
||
|
|
||
|
_, err := rand.Read(b)
|
||
|
|
||
|
return fmt.Sprintf("%x", b), err
|
||
|
}
|