MCPcopy
hub / github.com/syncthing/syncthing / String

Function String

lib/rand/random.go:40–48  ·  view source on GitHub ↗

String returns a cryptographically secure random string of characters (taken from randomCharset) of the specified length. The returned string contains ~5.8 bits of entropy per character, due to the character set used.

(l int)

Source from the content-addressed store, hash-verified

38// (taken from randomCharset) of the specified length. The returned string
39// contains ~5.8 bits of entropy per character, due to the character set used.
40func String(l int) string {
41 var sb strings.Builder
42 sb.Grow(l)
43
44 for range l {
45 sb.WriteByte(randomCharset[defaultSecureRand.Intn(len(randomCharset))])
46 }
47 return sb.String()
48}
49
50// Int63 returns a cryptographically secure random int63.
51func Int63() int64 {

Callers 15

TestIsEncryptedParentFunction · 0.92
TestInWriteableDirFunction · 0.92
TestOSWindowsRemoveFunction · 0.92
TestOSWindowsRemoveAllFunction · 0.92
initFunction · 0.92
newFolderConfigFunction · 0.92
TestReadOnlyDirFunction · 0.92
TestSetPlatformDataFunction · 0.92
newFakeConnectionFunction · 0.92
newTestFSFunction · 0.92
TestCachingFunction · 0.92

Calls 1

StringMethod · 0.65

Tested by 15

TestIsEncryptedParentFunction · 0.74
TestInWriteableDirFunction · 0.74
TestOSWindowsRemoveFunction · 0.74
TestOSWindowsRemoveAllFunction · 0.74
initFunction · 0.74
newFolderConfigFunction · 0.74
TestReadOnlyDirFunction · 0.74
TestSetPlatformDataFunction · 0.74
newFakeConnectionFunction · 0.74
newTestFSFunction · 0.74
TestCachingFunction · 0.74