initial refactor-servers commit

This commit is contained in:
wish
2023-12-04 00:00:40 +11:00
parent b6e7f019de
commit 4f889b1bf1
7 changed files with 122 additions and 101 deletions

View File

@@ -1,6 +1,7 @@
package token
import (
crand "crypto/rand"
"math/rand"
"time"
)
@@ -20,3 +21,10 @@ func Generate(length int) string {
func RNG() *rand.Rand {
return rand.New(rand.NewSource(time.Now().UnixNano()))
}
// RandBytes returns x random bytes
func RandBytes(x int) []byte {
y := make([]byte, x)
crand.Read(y)
return y
}