mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-23 13:54:04 +08:00
🐛 set random seed
This commit is contained in:
parent
86cda58b22
commit
a22903533e
@ -16,7 +16,6 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"math"
|
||||
mathRand "math/rand"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@ -462,7 +461,7 @@ func (driver Cloud189) UploadRequest(uri string, form map[string]string, account
|
||||
c := strconv.FormatInt(time.Now().UnixMilli(), 10)
|
||||
r := Random("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx")
|
||||
l := Random("xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx")
|
||||
l = l[0 : 16+int(16*mathRand.Float32())]
|
||||
l = l[0 : 16+int(16*utils.Rand.Float32())]
|
||||
|
||||
e := qs(form)
|
||||
data := AesEncrypt([]byte(e), []byte(l[0:16]))
|
||||
|
@ -14,18 +14,17 @@ import (
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/go-resty/resty/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
mathRand "math/rand"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func random() string {
|
||||
return fmt.Sprintf("0.%17v", mathRand.New(mathRand.NewSource(time.Now().UnixNano())).Int63n(100000000000000000))
|
||||
return fmt.Sprintf("0.%17v", utils.Rand.Int63n(100000000000000000))
|
||||
}
|
||||
|
||||
func RsaEncode(origData []byte, j_rsakey string, hex bool) string {
|
||||
@ -169,7 +168,7 @@ func Random(v string) string {
|
||||
reg := regexp.MustCompilePOSIX("[xy]")
|
||||
data := reg.ReplaceAllFunc([]byte(v), func(msg []byte) []byte {
|
||||
var i int64
|
||||
t := int64(16 * mathRand.Float32())
|
||||
t := int64(16 * utils.Rand.Float32())
|
||||
if msg[0] == 120 {
|
||||
i = t
|
||||
} else {
|
||||
|
@ -3,13 +3,22 @@ package utils
|
||||
import (
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Rand *rand.Rand
|
||||
|
||||
func init() {
|
||||
s := rand.NewSource(time.Now().UnixNano())
|
||||
Rand = rand.New(s)
|
||||
}
|
||||
|
||||
func RandomStr(n int) string {
|
||||
|
||||
builder := strings.Builder{}
|
||||
t := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
for i := 0; i < n; i++ {
|
||||
r := rand.Intn(len(t))
|
||||
r := Rand.Intn(len(t))
|
||||
builder.WriteString(t[r : r+1])
|
||||
}
|
||||
return builder.String()
|
||||
|
Loading…
x
Reference in New Issue
Block a user