MCPcopy Create free account
hub / github.com/devfeel/dotweb / GetRandString

Function GetRandString

framework/crypto/cryptos.go:19–30  ·  view source on GitHub ↗

GetRandString returns randominzed string with given length

(length int)

Source from the content-addressed store, hash-verified

17
18// GetRandString returns randominzed string with given length
19func GetRandString(length int) string {
20 var container string
21 var str = "0123456789abcdefghijklmnopqrstuvwxyz"
22 b := bytes.NewBufferString(str)
23 len := b.Len()
24 bigInt := big.NewInt(int64(len))
25 for i := 0; i < length; i++ {
26 randomInt, _ := rand.Int(rand.Reader, bigInt)
27 container += string(str[randomInt.Int64()])
28 }
29 return container
30}

Callers 1

Test_GetRandStringFunction · 0.85

Calls 1

LenMethod · 0.65

Tested by 1

Test_GetRandStringFunction · 0.68