OtpAlgorithm
Namespace: SimpleOTP
Represents the hashing algorithm used for One-Time Passwords.
public struct OtpAlgorithm
Inheritance Object → ValueType → OtpAlgorithm
Implements IEquatable<OtpAlgorithm>, IEquatable<String>, IXmlSerializable
Attributes SerializableAttribute, NullableContextAttribute, NullableAttribute, IsReadOnlyAttribute, JsonConverterAttribute
Properties
SHA1
The HMAC-SHA1 hashing algorithm.
public static OtpAlgorithm SHA1 { get; }
Property Value
SHA256
The HMAC-SHA256 hashing algorithm.
public static OtpAlgorithm SHA256 { get; }
Property Value
SHA512
The HMAC-SHA512 hashing algorithm.
public static OtpAlgorithm SHA512 { get; }
Property Value
MD5
The HMAC-MD5 hashing algorithm.
public static OtpAlgorithm MD5 { get; }
Property Value
Remarks:
This is not a standard algorithm, but it is defined by IIJ specification and recognized by default.
Internet Initiative Japan. URI format
Constructors
OtpAlgorithm(String)
Initializes a new instance of the OtpAlgorithm struct.
OtpAlgorithm(string value)
Parameters
value String
The algorithm to use.
Exceptions
ArgumentException
Thrown if value is empty or whitespace.
ArgumentNullException
Thrown if value is .
Methods
Equals(OtpAlgorithm)
bool Equals(OtpAlgorithm other)
Parameters
other OtpAlgorithm
Returns
Equals(String)
bool Equals(string other)
Parameters
other String
Returns
Equals(Object)
bool Equals(object obj)
Parameters
obj Object
Returns
IsStandard()
Determines whether the specified OtpAlgorithm is standard HMAC SHA algorithm (SHA-1, SHA-256 or SHA-512).
bool IsStandard()
Returns
Boolean
if the specified OtpAlgorithm is standard; otherwise, .
GetHashCode()
int GetHashCode()
Returns
ToString()
Returns the string representation of the OtpAlgorithm struct.
string ToString()
Returns
String
The string representation of the OtpAlgorithm struct.
GetSchema()
XmlSchema GetSchema()
Returns
XmlSchema
ReadXml(XmlReader)
void ReadXml(XmlReader reader)
Parameters
reader XmlReader
WriteXml(XmlWriter)
void WriteXml(XmlWriter writer)
Parameters
writer XmlWriter
IsStandard(String)
Determines whether the specified OtpAlgorithm is standard HMAC SHA algorithm (SHA-1, SHA-256 or SHA-512).
bool IsStandard(string algorithm)
Parameters
algorithm String
The algorithm to check.
Returns
Boolean
if the specified OtpAlgorithm is standard; otherwise, .
IsStandard(OtpAlgorithm)
Determines whether the specified OtpAlgorithm is standard HMAC SHA algorithm (SHA-1, SHA-256 or SHA-512).
bool IsStandard(OtpAlgorithm algorithm)
Parameters
algorithm OtpAlgorithm
The algorithm to check.
Returns
Boolean
if the specified OtpAlgorithm is standard; otherwise, .
©2025 Eugene Fox. Licensed under MIT license