-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
New uses bits 0-6 of each random byte (masks with 63) and the two high random bits are discarded.
I think it would be better not to discard randomness.
Lines 89 to 97 in 0cc1b25
bytes := make([]byte, size) | |
_, err := rand.Read(bytes) | |
if err != nil { | |
return "", err | |
} | |
id := make([]rune, size) | |
for i := 0; i < size; i++ { | |
id[i] = defaultAlphabet[bytes[i]&63] | |
} |
It is possible to write a loop and output 4 characters per each 3 random bytes and handle the remainder separately.
Or maybe reuse the base64 encoding code from standard library.
Metadata
Metadata
Assignees
Labels
No labels