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