crypto

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package crypto provides cryptographic utilities for the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateOTP

func GenerateOTP(digits int) (string, error)

GenerateOTP generates a cryptographically secure N-digit OTP. The digits parameter must be between 4 and 10.

func GenerateOTP4

func GenerateOTP4() (string, error)

GenerateOTP4 generates a cryptographically secure 4-digit OTP.

func GenerateOTP6

func GenerateOTP6() (string, error)

GenerateOTP6 generates a cryptographically secure 6-digit OTP. This is the most common OTP format.

func SecureCompare

func SecureCompare(a, b string) bool

SecureCompare performs constant-time string comparison. This prevents timing attacks when comparing secrets like OTP codes.

func SecureCompareBytes

func SecureCompareBytes(a, b []byte) bool

SecureCompareBytes performs constant-time byte slice comparison.

func ValidateOTPFormat

func ValidateOTPFormat(otp string, expectedDigits int) bool

ValidateOTPFormat validates that the OTP has the correct format. It checks that the OTP is exactly expectedDigits long and contains only digits. Note: This does NOT verify correctness, only format.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL