AshAuthentication.Strategy.Otp.DefaultGenerator
(ash_authentication v5.0.0-rc.6)
Copy Markdown
View Source
Default OTP code generator.
Generates random codes from a configurable character set and length.
Also provides normalize/1 for case-insensitive matching.
Ambiguous characters are excluded to avoid confusion when users read and type codes:
- Letters removed:
I(looks like1/l),L(looks like1/I),O(looks like0),S(looks like5),Z(looks like2) - Digits removed:
0(looks likeO),1(looks likeI/l),2(looks likeZ),5(looks likeS)
Summary
Functions
Generate a random OTP code.
Options:
:length- the length of the code (default: 6):characters- the character set to use (default::unambiguous_uppercase) Supported values::unambiguous_uppercase,:unambiguous_alphanumeric,:digits_only,:uppercase_letters_only
Normalize an OTP code for comparison.
Trims whitespace and converts to uppercase.