photoprism/pkg/rnd/passcode.go
Michael Mayer ab491c3032 2FA: Add generator for random 16-digit app passwords #808
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-11-27 19:43:53 +01:00

14 lines
411 B
Go

package rnd
// GeneratePasscode returns a random 16-digit passcode that can, for example, be used as an app password.
// It is separated by 3 dashes for better readability, resulting in a total length of 19 characters.
func GeneratePasscode() string {
code := make([]byte, 0, 19)
code = append(code, Base62(4)...)
for n := 0; n < 3; n++ {
code = append(code, "-"+Base62(4)...)
}
return string(code)
}