File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package dotweb
33// Global define
44const (
55 // Version current version
6- Version = "1.7.16 "
6+ Version = "1.7.17 "
77)
88
99// Log define
Original file line number Diff line number Diff line change @@ -670,7 +670,7 @@ func (app *DotWeb) printDotLogo() {
670670 app .Logger ().Print (` / / / / / __ \ / __/| | /| / / / _ \ / __ \` , LogTarget_HttpServer )
671671 app .Logger ().Print (` / /_/ / / /_/ // /_ | |/ |/ / / __/ / /_/ /` , LogTarget_HttpServer )
672672 app .Logger ().Print (`/_____/ \____/ \__/ |__/|__/ \___/ /_.___/` , LogTarget_HttpServer )
673- app .Logger ().Print (` Version 1.7.14` , LogTarget_HttpServer )
673+ app .Logger ().Print (` Version ` + Version , LogTarget_HttpServer )
674674}
675675
676676// Close immediately stops the server.
Original file line number Diff line number Diff line change 11package cryptos
22
33import (
4+ "bytes"
45 "crypto/md5"
5- "math /rand"
6+ "crypto /rand"
67 "encoding/hex"
7- "time "
8+ "math/big "
89)
910
1011// GetMd5String compute the md5 sum as string
@@ -16,11 +17,14 @@ func GetMd5String(s string) string {
1617
1718// GetRandString returns randominzed string with given length
1819func GetRandString (length int ) string {
19- bytes := []byte ("0123456789abcdefghijklmnopqrstuvwxyz" )
20- result := []byte {}
21- r := rand .New (rand .NewSource (time .Now ().UnixNano ()))
20+ var container string
21+ var str = "0123456789abcdefghijklmnopqrstuvwxyz"
22+ b := bytes .NewBufferString (str )
23+ len := b .Len ()
24+ bigInt := big .NewInt (int64 (len ))
2225 for i := 0 ; i < length ; i ++ {
23- result = append (result , bytes [r .Intn (len (bytes ))])
26+ randomInt , _ := rand .Int (rand .Reader , bigInt )
27+ container += string (str [randomInt .Int64 ()])
2428 }
25- return string ( result )
29+ return container
2630}
Original file line number Diff line number Diff line change @@ -17,6 +17,13 @@ func Test_GetMd5String_1(t *testing.T) {
1717
1818func Test_GetRandString (t * testing.T ) {
1919 randStr := GetRandString (12 )
20- t .Log ("GetRandString:" , randStr )
21- test .Equal (t , 12 , len (randStr ))
20+ rand1 := GetRandString (12 )
21+ rand2 := GetRandString (12 )
22+ rand3 := GetRandString (12 )
23+ if rand1 == rand2 || rand2 == rand3 || rand1 == rand3 {
24+ t .Error ("rand result is same" )
25+ } else {
26+ t .Log ("GetRandString:" , randStr )
27+ test .Equal (t , 12 , len (randStr ))
28+ }
2229}
Original file line number Diff line number Diff line change 11## dotweb版本记录:
22
3+ ####Version 1.7.17
4+ * Bug fix: fix GetRandString return same result
5+ * 2021-01-29 08:00 at ShangHai
6+
37####Version 1.7.16
48* Bug fix: fix middleware chain misbehaving in netsed groups
59* Tips: for issue #234 , thanks for @live 's code
You can’t perform that action at this time.
0 commit comments