Table of Contents
Base32Encoder
Namespace: SimpleOTP.Encoding
Provides methods for encoding and decoding data using the RFC 4648 Base32 standard alphabet.
public class Base32Encoder : IEncoder
Inheritance Object → Base32Encoder
Implements IEncoder
Attributes NullableContextAttribute, NullableAttribute
Properties
Instance
Gets the singleton instance of the Base32Encoder class.
public static Base32Encoder Instance { get; }
Property Value
Scheme
public string Scheme { get; }
Property Value
Constructors
Base32Encoder()
public Base32Encoder()
Methods
EncodeBytes(Byte[])
Converts a byte array to a Base32 string representation.
public string EncodeBytes(Byte[] bytes)
Parameters
bytes Byte[]
The byte array to convert.
Returns
String
The Base32 string representation of the byte array.
Exceptions
ArgumentNullException
Thrown when parameter is null.
GetBytes(String)
Converts a Base32 encoded string to a byte array.
public Byte[] GetBytes(string inArray)
Parameters
inArray String
The Base32 encoded string to convert.
Returns
Byte[]
The byte array representation of the Base32 encoded string.
Exceptions
ArgumentNullException
Thrown when parameter is null.
ArgumentException
Thrown when inArray is empty, whitespace, or contains invalid characters.
Remarks:
Trailing bits are ignored (e.g. AAAR will be treated as AAAQ - 0x00 0x01).
CharToValue(Char)
Converts a Base32 character to its numeric value.
protected int CharToValue(char c)
Parameters
c Char
The Base32 character to convert.
Returns
Int32
The numeric value of the Base32 character.
Exceptions
ArgumentException
Thrown when c is not a valid Base32 character.
ValueToChar(Int32)
Converts a numeric value to its Base32 character.
protected char ValueToChar(int value)
Parameters
value Int32
The numeric value to convert.
Returns
Char
The Base32 character corresponding to the numeric value.
Exceptions
ArgumentException
Thrown when value is not a valid Base32 value.
©2025 Eugene Fox. Licensed under MIT license