MCPcopy Create free account
hub / github.com/astercloud/aster / randomString

Function randomString

pkg/sandbox/local.go:1020–1030  ·  view source on GitHub ↗

randomString 生成随机字符串(使用 crypto/rand)

(n int)

Source from the content-addressed store, hash-verified

1018
1019// randomString 生成随机字符串(使用 crypto/rand)
1020func randomString(n int) string {
1021 b := make([]byte, n)
1022 if _, err := rand.Read(b); err != nil {
1023 // fallback to timestamp-based
1024 for i := range b {
1025 b[i] = byte('a' + (time.Now().UnixNano() % 26))
1026 }
1027 return string(b)
1028 }
1029 return hex.EncodeToString(b)[:n]
1030}
1031
1032// isExcludedCommand 检查命令是否在排除列表中
1033func (ls *LocalSandbox) isExcludedCommand(cmd string) bool {

Callers 2

TempMethod · 0.70
WatchMethod · 0.70

Calls 1

ReadMethod · 0.65

Tested by

no test coverage detected