generate agent_secret for old users (#1021)

This commit is contained in:
UUBulb
2025-03-08 18:47:42 +08:00
committed by GitHub
parent 79884c781a
commit 9ee5595da7
4 changed files with 31 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import (
"cmp"
"crypto/rand"
"errors"
"fmt"
"iter"
"maps"
"math/big"
@@ -82,6 +83,14 @@ func GenerateRandomString(n int) (string, error) {
return string(ret), nil
}
func MustGenerateRandomString(n int) string {
str, err := GenerateRandomString(n)
if err != nil {
panic(fmt.Errorf("MustGenerateRandomString: %v", err))
}
return str
}
func Uint64SubInt64(a uint64, b int64) uint64 {
if b < 0 {
return a + uint64(-b)