blob: 0b0f1cbd53f33ac3e4be069ca73eb282eff803ae (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package db
import (
"encoding/base64"
"lukechampine.com/blake3"
"math/rand"
)
func ToBlake3(pass string) string {
hash := blake3.Sum512([]byte(pass))
hash64b := base64.StdEncoding.EncodeToString(hash[:])
return "blake3-" + hash64b
}
func GenRandomString(n int) (string, error) {
b := make([]byte, n)
_, err := rand.Read(b)
if err != nil {
return "", err
}
return base64.URLEncoding.EncodeToString(b)[:n], nil
}
|