25 lines
324 B
Go
25 lines
324 B
Go
|
package generate
|
||
|
|
||
|
import (
|
||
|
"crypto/rand"
|
||
|
"encoding/hex"
|
||
|
|
||
|
"github.com/google/uuid"
|
||
|
)
|
||
|
|
||
|
func UUID() string {
|
||
|
// must be addressable
|
||
|
u := uuid.New()
|
||
|
|
||
|
return hex.EncodeToString(u[:])
|
||
|
}
|
||
|
|
||
|
func Hex(l int) string {
|
||
|
b := make([]byte, l)
|
||
|
if _, err := rand.Read(b); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
return hex.EncodeToString(b)
|
||
|
}
|