mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-09-21 02:19:05 +02:00
feat: add qr code alternative sign in method
This commit is contained in:
@@ -23,6 +23,12 @@ func GenerateRandomUnambiguousString(length int) (string, error) {
|
||||
return GenerateRandomString(length, charset)
|
||||
}
|
||||
|
||||
// GenerateRandomUppercaseUnambiguousString generates a random uppercase string of the given length using unambiguous characters
|
||||
func GenerateRandomUppercaseUnambiguousString(length int) (string, error) {
|
||||
const charset = "ABCDEFGHJKMNPQRSTUVWXYZ23456789"
|
||||
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) {
|
||||
|
||||
@@ -30,6 +36,10 @@ func GenerateRandomString(length int, charset string) (string, error) {
|
||||
return "", errors.New("length must be a positive integer")
|
||||
}
|
||||
|
||||
if len(charset) == 0 {
|
||||
return "", errors.New("character set must not be empty")
|
||||
}
|
||||
|
||||
// The algorithm below is adapted from https://stackoverflow.com/a/35615565
|
||||
const (
|
||||
letterIdxBits = 6 // 6 bits to represent a letter index
|
||||
|
||||
Reference in New Issue
Block a user