1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-07 05:55:40 +00:00

fix: remove ambiguous characters from login code

This commit is contained in:
Elias Schneider
2026-01-02 15:48:46 +01:00
parent b19d901618
commit d9e7bf9eef
7 changed files with 90 additions and 13 deletions

View File

@@ -14,6 +14,17 @@ import (
// GenerateRandomAlphanumericString generates a random alphanumeric string of the given length
func GenerateRandomAlphanumericString(length int) (string, error) {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
return GenerateRandomString(length, charset)
}
// GenerateRandomUnambiguousString generates a random string of the given length using unambiguous characters
func GenerateRandomUnambiguousString(length int) (string, error) {
const charset = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789"
return GenerateRandomString(length, charset)
}
// GenerateRandomString generates a random string of the given length using the provided character set
func GenerateRandomString(length int, charset string) (string, error) {
if length <= 0 {
return "", errors.New("length must be a positive integer")