34 lines
941 B
Python
34 lines
941 B
Python
import dotenv
|
|
import os
|
|
import random
|
|
dotenv.load_dotenv()
|
|
|
|
DEFAULT_SKIP = 0
|
|
DEFAULT_PAGE = 1
|
|
DEFAULT_LIMIT = 10
|
|
DEFAULT_ORDER = "id"
|
|
DEFAULT_ORDER_BY = "desc"
|
|
|
|
# jwt
|
|
JWT_ALGORITHM = os.getenv("JWT_ALGORITHM")
|
|
JWT_SECRET = os.getenv("JWT_SECRET")
|
|
JWT_EXPIRE_MINUTES = os.getenv("JWT_EXPIRE_MINUTES")
|
|
|
|
def generateOTP(length: int = 6) -> str:
|
|
"""
|
|
Generate a secure numeric OTP (One-Time Password) of specified length.
|
|
|
|
Args:
|
|
length: Length of the OTP to generate (default: 6)
|
|
|
|
Returns:
|
|
A string containing the generated numeric OTP
|
|
"""
|
|
if length < 4:
|
|
# Ensure minimum security with at least 4 characters
|
|
length = 4
|
|
|
|
# Generate a numeric OTP with exactly 'length' digits
|
|
# This ensures we get a number with the correct number of digits
|
|
# For example, length=6 gives a number between 100000-999999
|
|
return str(random.randint(10**(length-1), 10**length - 1)) |