Index
All Classes and Interfaces|All Packages|Constant Field Values|Serialized Form
A
- algorithm(Algorithm) - Method in class io.github.pratiyush.totp.TOTP.Builder
-
Sets the algorithm.
- algorithm(Algorithm) - Method in class io.github.pratiyush.totp.TOTPConfig.Builder
-
Sets the HMAC algorithm.
- Algorithm - Enum Class in io.github.pratiyush.totp
-
Supported HMAC algorithms for TOTP generation.
- Algorithm Recommendations - Search tag in enum class io.github.pratiyush.totp.Algorithm
- Section
- allowedDrift(int) - Method in class io.github.pratiyush.totp.TOTPConfig.Builder
-
Sets the allowed drift steps for verification.
B
- Base32Codec - Class in io.github.pratiyush.totp.internal
-
RFC 4648 compliant Base32 encoder/decoder with zero external dependencies.
- build() - Method in class io.github.pratiyush.totp.TOTP.Builder
-
Builds the TOTP instance.
- build() - Method in class io.github.pratiyush.totp.TOTPConfig.Builder
-
Builds the configuration.
- builder() - Static method in class io.github.pratiyush.totp.TOTP
-
Returns a builder for creating custom TOTP instances.
- builder() - Static method in class io.github.pratiyush.totp.TOTPConfig
-
Returns a builder with default values.
- buildOtpauthUri(String, String, String) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Builds an otpauth URI with default configuration.
- buildOtpauthUri(String, String, String, TOTPConfig) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Builds an otpauth URI for TOTP.
C
- clear() - Method in class io.github.pratiyush.totp.InMemoryReplayGuard
- clear() - Method in interface io.github.pratiyush.totp.ReplayGuard
-
Clears all tracked codes.
- clock(TOTPClock) - Method in class io.github.pratiyush.totp.TOTP.Builder
-
Sets the clock for time-based operations.
- close() - Method in class io.github.pratiyush.totp.InMemoryReplayGuard
-
Shuts down the background cleanup thread.
- close() - Method in class io.github.pratiyush.totp.internal.SecureBytes
-
Clears the underlying byte array by overwriting with zeros.
- compute(Algorithm, byte[], byte[]) - Static method in class io.github.pratiyush.totp.internal.HMACProvider
-
Computes HMAC using the specified algorithm.
- compute(String, byte[], byte[]) - Static method in class io.github.pratiyush.totp.internal.HMACProvider
-
Computes HMAC using the specified algorithm name.
- config(TOTPConfig) - Method in class io.github.pratiyush.totp.TOTP.Builder
-
Sets the TOTP configuration.
- constantTimeEquals(byte[], byte[]) - Static method in class io.github.pratiyush.totp.internal.SecureBytes
-
Constant-time comparison of two byte arrays.
- constantTimeEquals(String, String) - Static method in class io.github.pratiyush.totp.internal.TOTPEngine
-
Constant-time string comparison.
- copyOf(byte[]) - Static method in class io.github.pratiyush.totp.internal.SecureBytes
-
Creates a copy of the given byte array.
- copyOfRange(byte[], int, int) - Static method in class io.github.pratiyush.totp.internal.SecureBytes
-
Creates a SecureBytes from a portion of the given array.
- currentTimeSeconds() - Method in class io.github.pratiyush.totp.internal.TOTPClock
-
Returns the current Unix timestamp in seconds.
- Custom Configuration - Search tag in class io.github.pratiyush.totp.TOTP
- Section
D
- decode(String) - Static method in class io.github.pratiyush.totp.internal.Base32Codec
-
Decodes a Base32 string to binary data.
- decodedLength(int) - Static method in class io.github.pratiyush.totp.internal.Base32Codec
-
Returns the expected decoded size for a Base32 string length.
- DEFAULT_BYTES - Static variable in class io.github.pratiyush.totp.SecretGenerator
-
Default secret size in bytes (160 bits for SHA-1 compatibility)
- DEFAULT_SIZE - Static variable in class io.github.pratiyush.totp.QRCodeGenerator
-
Default QR code size in pixels
- defaultConfig() - Static method in class io.github.pratiyush.totp.TOTPConfig
-
Returns the default configuration (Google Authenticator compatible).
- Default Configuration - Search tag in class io.github.pratiyush.totp.TOTPConfig
- Section
- defaultInstance() - Static method in class io.github.pratiyush.totp.TOTP
-
Returns a TOTP instance with default configuration.
- Dependencies - Search tag in class io.github.pratiyush.totp.QRCodeGenerator
- Section
- digits(int) - Method in class io.github.pratiyush.totp.TOTPConfig.Builder
-
Sets the number of digits in generated codes.
E
- encode(byte[]) - Static method in class io.github.pratiyush.totp.internal.Base32Codec
-
Encodes binary data to Base32 string without padding.
- encode(byte[], boolean) - Static method in class io.github.pratiyush.totp.internal.Base32Codec
-
Encodes binary data to Base32 string.
- encodedLength(int) - Static method in class io.github.pratiyush.totp.internal.Base32Codec
-
Returns the expected output size for a given input size.
- entropyBits(int) - Static method in class io.github.pratiyush.totp.SecretGenerator
-
Returns the entropy in bits for a given Base32 secret length.
- equals(Object) - Method in class io.github.pratiyush.totp.TOTPConfig
- Error Codes - Search tag in exception class io.github.pratiyush.totp.TOTPException
- Section
F
- Features - Search tag in class io.github.pratiyush.totp.InMemoryReplayGuard
- Section
- Features - Search tag in class io.github.pratiyush.totp.internal.Base32Codec
- Section
- fixed(Instant) - Static method in class io.github.pratiyush.totp.internal.TOTPClock
-
Creates a clock fixed at the specified instant.
- forConfig(TOTPConfig) - Static method in class io.github.pratiyush.totp.InMemoryReplayGuard
-
Creates a replay guard configured for a specific TOTP configuration.
- fromName(String) - Static method in enum class io.github.pratiyush.totp.Algorithm
-
Parses an algorithm from its JCA name or enum name.
G
- generate() - Static method in class io.github.pratiyush.totp.SecretGenerator
-
Generates a secret with default length (160 bits).
- generate(int) - Static method in class io.github.pratiyush.totp.SecretGenerator
-
Generates a secret with the specified length in bytes.
- generate(Algorithm) - Static method in class io.github.pratiyush.totp.SecretGenerator
-
Generates a secret with appropriate length for the specified algorithm.
- generate(String) - Method in class io.github.pratiyush.totp.TOTP
-
Generates a TOTP code for the current time.
- generateAt(String, Instant) - Method in class io.github.pratiyush.totp.TOTP
-
Generates a TOTP code for a specific instant.
- generateBase64(String, String, String, int) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Generates a QR code as Base64 encoded PNG.
- generateBase64(String, String, String, int, TOTPConfig) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Generates a QR code as Base64 encoded PNG with custom configuration.
- generateBytes(int) - Static method in class io.github.pratiyush.totp.SecretGenerator
-
Generates raw random bytes.
- generateCode(byte[], long, TOTPConfig) - Static method in class io.github.pratiyush.totp.internal.TOTPEngine
-
Generates a TOTP code for the given secret and counter.
- generateCode(byte[], TOTPConfig, TOTPClock) - Static method in class io.github.pratiyush.totp.internal.TOTPEngine
-
Generates a TOTP code for the current time.
- generateCodeAt(byte[], Instant, TOTPConfig) - Static method in class io.github.pratiyush.totp.internal.TOTPEngine
-
Generates a TOTP code for a specific instant.
- generateDataUri(String, String, String, int) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Generates a data URI for embedding in HTML.
- generateForCounter(String, long) - Method in class io.github.pratiyush.totp.TOTP
-
Generates a TOTP code for a specific counter value.
- generateImage(String, String, String, int) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Generates a QR code image.
- generateImage(String, String, String, int, TOTPConfig) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Generates a QR code image with custom configuration.
- getAlgorithm() - Method in class io.github.pratiyush.totp.TOTPConfig
-
Returns the HMAC algorithm.
- getAllowedDrift() - Method in class io.github.pratiyush.totp.TOTPConfig
-
Returns the allowed drift steps for verification.
- getBytes() - Method in class io.github.pratiyush.totp.internal.SecureBytes
-
Returns the underlying byte array.
- getClock() - Method in class io.github.pratiyush.totp.TOTP
-
Returns the clock being used.
- getConfig() - Method in class io.github.pratiyush.totp.TOTP
-
Returns the configuration.
- getCounterForInstant(Instant, int) - Static method in class io.github.pratiyush.totp.internal.TOTPClock
-
Returns the counter value for a specific timestamp.
- getCurrentCounter() - Method in class io.github.pratiyush.totp.TOTP
-
Returns the current TOTP counter value.
- getCurrentCounter(int) - Method in class io.github.pratiyush.totp.internal.TOTPClock
-
Returns the current TOTP counter value.
- getDigits() - Method in class io.github.pratiyush.totp.TOTPConfig
-
Returns the number of digits in generated codes.
- getErrorCode() - Method in exception class io.github.pratiyush.totp.TOTPException
-
Returns the error code for this exception.
- getJavaClock() - Method in class io.github.pratiyush.totp.internal.TOTPClock
-
Returns the underlying Java Clock.
- getJcaName() - Method in enum class io.github.pratiyush.totp.Algorithm
-
Returns the Java Cryptography Architecture (JCA) algorithm name.
- getMessage() - Method in class io.github.pratiyush.totp.TOTP.VerificationResult
-
Returns a human-readable message.
- getOtpauthName() - Method in enum class io.github.pratiyush.totp.Algorithm
-
Returns the otpauth URI algorithm parameter value.
- getPeriod() - Method in class io.github.pratiyush.totp.TOTPConfig
-
Returns the time period for code validity.
- getPeriodSeconds() - Method in class io.github.pratiyush.totp.TOTPConfig
-
Returns the period in seconds.
- getRecommendedKeyBytes() - Method in enum class io.github.pratiyush.totp.Algorithm
-
Returns the recommended key size in bytes for this algorithm.
- getRecommendedSecretLength() - Method in enum class io.github.pratiyush.totp.Algorithm
-
Returns the recommended secret length in Base32 characters.
- getRetention() - Method in class io.github.pratiyush.totp.InMemoryReplayGuard
-
Returns the configured retention period.
- getSecondsRemaining() - Method in class io.github.pratiyush.totp.TOTP
-
Returns seconds remaining until the current code expires.
- getSecondsRemaining(int) - Method in class io.github.pratiyush.totp.internal.TOTPClock
-
Returns the number of seconds remaining in the current period.
- getTimeOffset() - Method in class io.github.pratiyush.totp.TOTP.VerificationResult
-
Returns the time offset of the matching code.
H
- hashCode() - Method in class io.github.pratiyush.totp.TOTPConfig
- highSecurityConfig() - Static method in class io.github.pratiyush.totp.TOTPConfig
-
Returns a high-security configuration with SHA-512 and 8 digits.
- HMAC_ERROR - Enum constant in enum class io.github.pratiyush.totp.TOTPException.ErrorCode
-
HMAC computation failed (algorithm not available, etc.)
- hmacError(Throwable) - Static method in exception class io.github.pratiyush.totp.TOTPException
-
Creates an exception for HMAC errors.
- HMACProvider - Class in io.github.pratiyush.totp.internal
-
Secure HMAC computation for TOTP.
I
- Implementation Notes - Search tag in interface io.github.pratiyush.totp.ReplayGuard
- Section
- InMemoryReplayGuard - Class in io.github.pratiyush.totp
-
Thread-safe in-memory implementation of
ReplayGuard. - InMemoryReplayGuard(Duration) - Constructor for class io.github.pratiyush.totp.InMemoryReplayGuard
-
Creates a new in-memory replay guard with the specified retention period.
- INTERNAL_ERROR - Enum constant in enum class io.github.pratiyush.totp.TOTPException.ErrorCode
-
Unexpected internal error
- internalError(String, Throwable) - Static method in exception class io.github.pratiyush.totp.TOTPException
-
Creates an exception for internal errors.
- INVALID_CODE - Enum constant in enum class io.github.pratiyush.totp.TOTPException.ErrorCode
-
Code format is invalid (wrong length, non-numeric, etc.)
- INVALID_CONFIG - Enum constant in enum class io.github.pratiyush.totp.TOTPException.ErrorCode
-
Configuration parameters are invalid
- INVALID_SECRET - Enum constant in enum class io.github.pratiyush.totp.TOTPException.ErrorCode
-
Secret is null, empty, too short, or contains invalid characters
- invalidCode(String) - Static method in exception class io.github.pratiyush.totp.TOTPException
-
Creates an exception for invalid codes.
- invalidConfig(String) - Static method in exception class io.github.pratiyush.totp.TOTPException
-
Creates an exception for invalid configuration.
- invalidSecret(String) - Static method in exception class io.github.pratiyush.totp.TOTPException
-
Creates an exception for invalid secrets.
- io.github.pratiyush.totp - package io.github.pratiyush.totp
-
Production-Ready TOTP Library - Null Safety Declaration.
- io.github.pratiyush.totp.internal - package io.github.pratiyush.totp.internal
-
Internal implementation classes for the TOTP library.
- isAlgorithmAvailable(Algorithm) - Static method in class io.github.pratiyush.totp.internal.HMACProvider
-
Checks if an algorithm is available in the current JVM.
- isAlgorithmAvailable(String) - Static method in class io.github.pratiyush.totp.internal.HMACProvider
-
Checks if an algorithm is available in the current JVM.
- isCleared() - Method in class io.github.pratiyush.totp.internal.SecureBytes
-
Returns whether this instance has been cleared.
- isValid() - Method in class io.github.pratiyush.totp.TOTP.VerificationResult
-
Returns whether the code was valid.
- isValid(String) - Static method in class io.github.pratiyush.totp.SecretGenerator
-
Validates that a secret meets minimum security requirements.
- isValid(String) - Static method in class io.github.pratiyush.totp.internal.Base32Codec
-
Validates a Base32 string without decoding.
- isValidCodeFormat(String, int) - Static method in class io.github.pratiyush.totp.internal.TOTPEngine
-
Checks if a code string has valid format.
L
- length() - Method in class io.github.pratiyush.totp.internal.SecureBytes
-
Returns the length of the data.
- Limitations - Search tag in class io.github.pratiyush.totp.InMemoryReplayGuard
- Section
M
- markUsed(String) - Method in class io.github.pratiyush.totp.InMemoryReplayGuard
- markUsed(String) - Method in interface io.github.pratiyush.totp.ReplayGuard
-
Attempts to mark a code as used.
- MAX_DIGITS - Static variable in class io.github.pratiyush.totp.TOTPConfig
-
Maximum allowed digits
- MAX_DRIFT_STEPS - Static variable in class io.github.pratiyush.totp.TOTPConfig
-
Maximum allowed drift steps
- MAX_PERIOD_SECONDS - Static variable in class io.github.pratiyush.totp.TOTPConfig
-
Maximum allowed period in seconds
- MAX_SIZE - Static variable in class io.github.pratiyush.totp.QRCodeGenerator
-
Maximum QR code size in pixels
- MIN_BYTES - Static variable in class io.github.pratiyush.totp.SecretGenerator
-
Minimum allowed secret size in bytes
- MIN_DIGITS - Static variable in class io.github.pratiyush.totp.TOTPConfig
-
Minimum allowed digits
- MIN_PERIOD_SECONDS - Static variable in class io.github.pratiyush.totp.TOTPConfig
-
Minimum allowed period in seconds
- MIN_SECRET_BYTES - Static variable in class io.github.pratiyush.totp.internal.TOTPEngine
-
Minimum secret length in bytes for security
- MIN_SIZE - Static variable in class io.github.pratiyush.totp.QRCodeGenerator
-
Minimum QR code size in pixels
N
- now() - Method in class io.github.pratiyush.totp.internal.TOTPClock
-
Returns the current time as an Instant.
O
- of(Clock) - Static method in class io.github.pratiyush.totp.internal.TOTPClock
-
Creates a clock from a Java Clock instance.
- otpauth URI Format - Search tag in class io.github.pratiyush.totp.QRCodeGenerator
- Section
P
- period(Duration) - Method in class io.github.pratiyush.totp.TOTPConfig.Builder
-
Sets the time period for code validity.
- periodSeconds(int) - Method in class io.github.pratiyush.totp.TOTPConfig.Builder
-
Sets the period in seconds.
Q
- QR_GENERATION_ERROR - Enum constant in enum class io.github.pratiyush.totp.TOTPException.ErrorCode
-
QR code generation failed
- QRCodeGenerator - Class in io.github.pratiyush.totp
-
Generates QR codes for TOTP secrets compatible with authenticator apps.
- qrGenerationError(Throwable) - Static method in exception class io.github.pratiyush.totp.TOTPException
-
Creates an exception for QR generation errors.
- Quick Start - Search tag in class io.github.pratiyush.totp.TOTP
- Section
R
- recommendedLength(Algorithm) - Static method in class io.github.pratiyush.totp.SecretGenerator
-
Returns the recommended secret length for a given algorithm.
- replayGuard(ReplayGuard) - Method in class io.github.pratiyush.totp.TOTP.Builder
-
Sets the replay guard.
- ReplayGuard - Interface in io.github.pratiyush.totp
-
Interface for preventing TOTP code replay attacks.
- RFC Compliance - Search tag in class io.github.pratiyush.totp.internal.TOTPEngine
- Section
S
- saveToFile(String, String, String, Path, int) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Saves a QR code to a file.
- saveToFile(String, String, String, Path, int, TOTPConfig) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Saves a QR code to a file with custom configuration.
- SecretGenerator - Class in io.github.pratiyush.totp
-
Secure generator for TOTP secrets.
- SecureBytes - Class in io.github.pratiyush.totp.internal
-
A wrapper for byte arrays containing sensitive data that ensures secure clearing.
- Security Features - Search tag in class io.github.pratiyush.totp.TOTP
- Section
- Security Note - Search tag in exception class io.github.pratiyush.totp.TOTPException
- Section
- Security Notes - Search tag in class io.github.pratiyush.totp.internal.HMACProvider
- Section
- Security Notes - Search tag in class io.github.pratiyush.totp.internal.SecureBytes
- Section
- Security Recommendations - Search tag in class io.github.pratiyush.totp.SecretGenerator
- Section
- SHA1 - Enum constant in enum class io.github.pratiyush.totp.Algorithm
-
HMAC-SHA1 algorithm.
- SHA256 - Enum constant in enum class io.github.pratiyush.totp.Algorithm
-
HMAC-SHA256 algorithm.
- sha256Config() - Static method in class io.github.pratiyush.totp.TOTPConfig
-
Returns a configuration optimized for SHA-256.
- SHA512 - Enum constant in enum class io.github.pratiyush.totp.Algorithm
-
HMAC-SHA512 algorithm.
- size() - Method in class io.github.pratiyush.totp.InMemoryReplayGuard
- size() - Method in interface io.github.pratiyush.totp.ReplayGuard
-
Returns the number of codes currently tracked.
- systemUTC() - Static method in class io.github.pratiyush.totp.internal.TOTPClock
-
Creates a clock using the system UTC time.
T
- Thread Safety - Search tag in class io.github.pratiyush.totp.TOTP
- Section
- Thread Safety - Search tag in class io.github.pratiyush.totp.internal.HMACProvider
- Section
- Thread Safety - Search tag in class io.github.pratiyush.totp.internal.TOTPEngine
- Section
- toString() - Method in class io.github.pratiyush.totp.internal.SecureBytes
-
Returns a safe string representation that never reveals the data.
- toString() - Method in class io.github.pratiyush.totp.TOTP.VerificationResult
- toString() - Method in class io.github.pratiyush.totp.TOTPConfig
- toString() - Method in exception class io.github.pratiyush.totp.TOTPException
- TOTP - Class in io.github.pratiyush.totp
-
Main entry point for TOTP operations.
- TOTP.Builder - Class in io.github.pratiyush.totp
-
Builder for creating TOTP instances.
- TOTP.VerificationResult - Class in io.github.pratiyush.totp
-
Result of a TOTP verification with additional details.
- TOTPClock - Class in io.github.pratiyush.totp.internal
-
Provides time for TOTP calculations with support for testing.
- TOTPConfig - Class in io.github.pratiyush.totp
-
Immutable configuration for TOTP generation and verification.
- TOTPConfig.Builder - Class in io.github.pratiyush.totp
-
Builder for creating
TOTPConfiginstances. - TOTPEngine - Class in io.github.pratiyush.totp.internal
-
Core TOTP engine implementing RFC 6238.
- TOTPException - Exception Class in io.github.pratiyush.totp
-
Exception thrown for TOTP-related errors.
- TOTPException.ErrorCode - Enum Class in io.github.pratiyush.totp
-
Error codes for programmatic error handling.
U
- Usage Example - Search tag in class io.github.pratiyush.totp.InMemoryReplayGuard
- Section
- Usage Example - Search tag in class io.github.pratiyush.totp.internal.SecureBytes
- Section
- Usage Examples - Search tag in class io.github.pratiyush.totp.QRCodeGenerator
- Section
- Usage Examples - Search tag in class io.github.pratiyush.totp.SecretGenerator
- Section
- Usage Examples - Search tag in class io.github.pratiyush.totp.TOTPConfig
- Section
- Usage Examples - Search tag in class io.github.pratiyush.totp.internal.TOTPClock
- Section
- Usage Pattern - Search tag in interface io.github.pratiyush.totp.ReplayGuard
- Section
V
- validateBase32Secret(String) - Static method in class io.github.pratiyush.totp.internal.TOTPEngine
-
Validates a Base32 encoded secret.
- validateSecret(byte[]) - Static method in class io.github.pratiyush.totp.internal.TOTPEngine
-
Validates that the secret meets minimum security requirements.
- valueOf(String) - Static method in enum class io.github.pratiyush.totp.Algorithm
-
Returns the enum constant of this class with the specified name.
- valueOf(String) - Static method in enum class io.github.pratiyush.totp.TOTPException.ErrorCode
-
Returns the enum constant of this class with the specified name.
- values() - Static method in enum class io.github.pratiyush.totp.Algorithm
-
Returns an array containing the constants of this enum class, in the order they are declared.
- values() - Static method in enum class io.github.pratiyush.totp.TOTPException.ErrorCode
-
Returns an array containing the constants of this enum class, in the order they are declared.
- verify(String, String) - Method in class io.github.pratiyush.totp.TOTP
-
Verifies a TOTP code.
- verify(String, String, String) - Method in class io.github.pratiyush.totp.TOTP
-
Verifies a TOTP code with user-specific replay protection.
- verifyCode(byte[], String, TOTPConfig, TOTPClock) - Static method in class io.github.pratiyush.totp.internal.TOTPEngine
-
Verifies a TOTP code using constant-time comparison.
- verifyCodeWithOffset(byte[], String, TOTPConfig, TOTPClock) - Static method in class io.github.pratiyush.totp.internal.TOTPEngine
-
Verifies a code and returns the matching counter offset if valid.
- verifyWithDetails(String, String) - Method in class io.github.pratiyush.totp.TOTP
-
Verifies a code and returns detailed result.
W
- wasUsed(String) - Method in class io.github.pratiyush.totp.InMemoryReplayGuard
- wasUsed(String) - Method in interface io.github.pratiyush.totp.ReplayGuard
-
Checks if a code has been used without marking it.
- withDefaultRetention() - Static method in class io.github.pratiyush.totp.InMemoryReplayGuard
-
Creates a replay guard with default retention of 2 minutes.
- withReplayProtection() - Method in class io.github.pratiyush.totp.TOTP.Builder
-
Enables replay protection with default retention.
- withReplayProtection(Duration) - Method in class io.github.pratiyush.totp.TOTP.Builder
-
Enables replay protection with an in-memory guard.
- wrap(byte[]) - Static method in class io.github.pratiyush.totp.internal.SecureBytes
-
Wraps an existing byte array.
- writeTo(String, String, String, OutputStream, String, int) - Static method in class io.github.pratiyush.totp.QRCodeGenerator
-
Writes a QR code to an output stream.
All Classes and Interfaces|All Packages|Constant Field Values|Serialized Form