Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dotweb
// Global define
const (
// Version current version
Version = "1.7.16"
Version = "1.7.17"
)

// Log define
Expand Down
2 changes: 1 addition & 1 deletion dotweb.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ func (app *DotWeb) printDotLogo() {
app.Logger().Print(` / / / / / __ \ / __/| | /| / / / _ \ / __ \`, LogTarget_HttpServer)
app.Logger().Print(` / /_/ / / /_/ // /_ | |/ |/ / / __/ / /_/ /`, LogTarget_HttpServer)
app.Logger().Print(`/_____/ \____/ \__/ |__/|__/ \___/ /_.___/`, LogTarget_HttpServer)
app.Logger().Print(` Version 1.7.14`, LogTarget_HttpServer)
app.Logger().Print(` Version `+Version, LogTarget_HttpServer)
}

// Close immediately stops the server.
Expand Down
18 changes: 11 additions & 7 deletions framework/crypto/cryptos.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cryptos

import (
"bytes"
"crypto/md5"
"math/rand"
"crypto/rand"
"encoding/hex"
"time"
"math/big"
)

// GetMd5String compute the md5 sum as string
Expand All @@ -16,11 +17,14 @@ func GetMd5String(s string) string {

// GetRandString returns randominzed string with given length
func GetRandString(length int) string {
bytes := []byte("0123456789abcdefghijklmnopqrstuvwxyz")
result := []byte{}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
var container string
var str = "0123456789abcdefghijklmnopqrstuvwxyz"
b := bytes.NewBufferString(str)
len := b.Len()
bigInt := big.NewInt(int64(len))
for i := 0; i < length; i++ {
result = append(result, bytes[r.Intn(len(bytes))])
randomInt, _ := rand.Int(rand.Reader, bigInt)
container += string(str[randomInt.Int64()])
}
return string(result)
return container
}
11 changes: 9 additions & 2 deletions framework/crypto/cryptos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ func Test_GetMd5String_1(t *testing.T) {

func Test_GetRandString(t *testing.T) {
randStr := GetRandString(12)
t.Log("GetRandString:", randStr)
test.Equal(t, 12, len(randStr))
rand1 := GetRandString(12)
rand2 := GetRandString(12)
rand3 := GetRandString(12)
if rand1 == rand2 || rand2 == rand3 || rand1 == rand3 {
t.Error("rand result is same")
} else {
t.Log("GetRandString:", randStr)
test.Equal(t, 12, len(randStr))
}
}
4 changes: 4 additions & 0 deletions version.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## dotweb版本记录:

####Version 1.7.17
* Bug fix: fix GetRandString return same result
* 2021-01-29 08:00 at ShangHai

####Version 1.7.16
* Bug fix: fix middleware chain misbehaving in netsed groups
* Tips: for issue #234, thanks for @live's code
Expand Down