Hotp
Namespace: SimpleOTP
Represents a HOTP (HMAC-based One-Time Password) generator.
public class Hotp : Otp
Inheritance Object → Otp → Hotp
Attributes NullableContextAttribute, NullableAttribute
Properties
Counter
Gets or sets the counter value used for generating OTP codes.
public long Counter { get; set; }
Property Value
Secret
Gets or sets the secret key used for generating OTPs.
public OtpSecret Secret { get; set; }
Property Value
Algorithm
Gets or sets the algorithm used for generating OTP codes.
public OtpAlgorithm Algorithm { get; set; }
Property Value
Digits
Gets or sets the number of digits in the OTP code.
public int Digits { get; set; }
Property Value
Int32
Default: 6. Recommended: 6-8.
Constructors
Hotp(OtpSecret)
Initializes a new instance of the Hotp class
public Hotp(OtpSecret secret)
Parameters
secret OtpSecret
The secret key used for generating OTP codes.
Hotp(OtpSecret, Int64)
Initializes a new instance of the Hotp class
public Hotp(OtpSecret secret, long counter)
Parameters
secret OtpSecret
The secret key used for generating OTP codes.
counter Int64
The counter value used for generating OTP codes.
Hotp(OtpSecret, Int64, Int32)
Initializes a new instance of the Hotp class
public Hotp(OtpSecret secret, long counter, int digits)
Parameters
secret OtpSecret
The secret key used for generating OTP codes.
counter Int64
The counter value used for generating OTP codes.
digits Int32
The number of digits in the OTP code.
Hotp(OtpSecret, Int64, OtpAlgorithm)
Initializes a new instance of the Hotp class
public Hotp(OtpSecret secret, long counter, OtpAlgorithm algorithm)
Parameters
secret OtpSecret
The secret key used for generating OTP codes.
counter Int64
The counter value used for generating OTP codes.
algorithm OtpAlgorithm
The algorithm used for generating OTP codes.
Hotp(OtpSecret, Int64, OtpAlgorithm, Int32)
Initializes a new instance of the Hotp class
public Hotp(OtpSecret secret, long counter, OtpAlgorithm algorithm, int digits)
Parameters
secret OtpSecret
The secret key used for generating OTP codes.
counter Int64
The counter value used for generating OTP codes.
algorithm OtpAlgorithm
The algorithm used for generating OTP codes.
digits Int32
The number of digits in the OTP code.
Methods
GetCounter()
Gets the current counter value.
protected long GetCounter()
Returns
Int64
The current counter value.
©2025 Eugene Fox. Licensed under MIT license