This commit is contained in:
兔子
2023-08-26 12:54:46 +08:00
parent 3c8e339126
commit ce7cccf7cc

View File

@@ -15,6 +15,8 @@ import (
"fmt"
"github.com/spf13/cast"
"hash/fnv"
rand2 "math/rand"
"time"
)
type HashStruct struct{}
@@ -71,6 +73,25 @@ func (this *HashStruct) Token(value any, args ...any) (result string) {
return item
}
// Number 生成指定长度的随机数
/**
* @param length 长度
* @return result 随机数
* @example
* 1. number := facade.Hash.Number(6)
*/
func (this *HashStruct) Number(length any) (result string) {
// 生成一个随机种子
rand2.NewSource(time.Now().UnixNano())
// 生成一个随机数
for i := 0; i < cast.ToInt(length); i++ {
result += fmt.Sprintf("%d", rand2.Intn(10))
}
return result
}
// AESRequest - 请求输入
type AESRequest struct {
// 16位密钥