MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Krand

Function Krand

utils/krand.go:16–29  ·  view source on GitHub ↗

随机字符串

(size int, kind int)

Source from the content-addressed store, hash-verified

14
15// 随机字符串
16func Krand(size int, kind int) []byte {
17 ikind, kinds, result := kind, [][]int{[]int{10, 48}, []int{26, 97}, []int{26, 65}}, make([]byte, size)
18 isAll := kind > KC_RAND_KIND_UPPER || kind < KC_RAND_KIND_NUM
19 rand.Seed(time.Now().UnixNano())
20 for i := 0; i < size; i++ {
21 if isAll { // random ikind
22 ikind = rand.Intn(3)
23 }
24 scope, base := kinds[ikind][0], kinds[ikind][1]
25 result[i] = uint8(base + rand.Intn(scope))
26 }
27
28 return result
29}

Callers 3

FindPasswordMethod · 0.92
CreateTokenMethod · 0.92
CreateTokenMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected