Class: Otp::Generate
- Inherits:
-
Object
- Object
- Otp::Generate
- Defined in:
- lib/otp/generate.rb
Overview
This class provides functionality to generate a One-Time Password (OTP). It generates a random numeric string of a specified length, which defaults to 6 digits.
Constant Summary collapse
- OTP_LENGTH =
6
Class Method Summary collapse
-
.call ⇒ String
Generates a random OTP of the specified length.
Class Method Details
.call ⇒ String
Generates a random OTP of the specified length.
9 10 11 |
# File 'lib/otp/generate.rb', line 9 def self.call SecureRandom.random_number(10**OTP_LENGTH).to_s.rjust(OTP_LENGTH, "0") end |