Skip to content

simpleotp.otpcode

Eugene Fox edited this page Sep 18, 2024 · 1 revision

OtpCode

Namespace: SimpleOTP

Represents a one-time password (OTP) code.

public struct OtpCode

Inheritance ObjectValueTypeOtpCode
Implements IEquatable<OtpCode>, IEquatable<String>, IXmlSerializable
Attributes SerializableAttribute, NullableContextAttribute, NullableAttribute, IsReadOnlyAttribute, JsonConverterAttribute

Properties

CanExpire

Gets a value indicating whether the OTP code can expire (true for TOTP, false for HOTP).

public bool CanExpire { get; }

Property Value

Boolean

ExpirationTime

Gets the expiration time of the OTP code (TOTP only).

public Nullable<DateTimeOffset> ExpirationTime { get; }

Property Value

Nullable<DateTimeOffset>

Constructors

OtpCode(Int32, Int32)

Initializes a new instance of the OtpCode struct with the specified value with no expiration time.

OtpCode(int code, int digits)

Parameters

code Int32
The value of the OTP code.

digits Int32
The number of digits in the OTP code.

Exceptions

ArgumentNullException
code is .

ArgumentException
code is not a valid numeric code.

OtpCode(Int32, Int32, Nullable<DateTimeOffset>)

Initializes a new instance of the OtpCode struct with the specified value and the expiration time.

OtpCode(int code, int digits, Nullable<DateTimeOffset> expirationTime)

Parameters

code Int32
The value of the OTP code.

digits Int32
The number of digits in the OTP code.

expirationTime Nullable<DateTimeOffset>
The expiration time of the OTP code (TOTP only).

Exceptions

ArgumentNullException
code is .

ArgumentException
code is not a valid numeric code.

OtpCode(String)

Initializes a new instance of the OtpCode struct with the specified value with no expiration time.

OtpCode(string code)

Parameters

code String
The value of the OTP code.

Exceptions

ArgumentNullException
code is .

ArgumentException
code is not a valid numeric code.

OtpCode(String, Nullable<DateTimeOffset>)

Initializes a new instance of the OtpCode struct with the specified value and the expiration time.

OtpCode(string code, Nullable<DateTimeOffset> expirationTime)

Parameters

code String
The value of the OTP code.

expirationTime Nullable<DateTimeOffset>
The expiration time of the OTP code (TOTP only).

Exceptions

ArgumentNullException
code is .

ArgumentException
code is not a valid numeric code.

Methods

ToString()

Returns a string representation of the OTP code.

string ToString()

Returns

String
A string representation of the OTP code.

ToString(String)

Returns a string representation of the OTP code.

string ToString(string format)

Parameters

format String
The format to use.

Returns

String
The string representation of the OTP code.

Equals(OtpCode)

bool Equals(OtpCode other)

Parameters

other OtpCode

Returns

Boolean

Equals(Object)

bool Equals(object obj)

Parameters

obj Object

Returns

Boolean

Equals(String)

bool Equals(string other)

Parameters

other String

Returns

Boolean

GetHashCode()

int GetHashCode()

Returns

Int32

GetSchema()

XmlSchema GetSchema()

Returns

XmlSchema

ReadXml(XmlReader)

void ReadXml(XmlReader reader)

Parameters

reader XmlReader

WriteXml(XmlWriter)

void WriteXml(XmlWriter writer)

Parameters

writer XmlWriter

Parse(String)

Parses the specified String into an OtpCode object.

OtpCode Parse(string code)

Parameters

code String
The string to parse.

Returns

OtpCode
An OtpCode object.

Exceptions

ArgumentNullException
code is .

ArgumentException
code is not a valid numeric code.

TryParse(String, OtpCode&)

Tries to parse the specified String into an OtpCode object.

bool TryParse(string code, OtpCode& result)

Parameters

code String
The string to parse.

result OtpCode&
The parsed OtpCode object.

Returns

Boolean
if code was parsed successfully; otherwise, .

Clone this wiki locally