Table of Contents

Class EncodingUtils

Namespace
NanoByte.Common
Assembly
NanoByte.Common.dll

Helper methods for encoding strings, decoding byte arrays, calculating hashes, etc..

public static class EncodingUtils
Inheritance
object
EncodingUtils

Fields

Utf8

UTF-8 encoding without BOM (byte order marker).

public static readonly Encoding Utf8

Field Value

Encoding

Methods

Base16Decode(string)

Decodes a base16 (hexadecimal) to a byte array.

public static byte[] Base16Decode(this string value)

Parameters

value string

Returns

byte[]

Base16Encode(byte[])

Encodes a byte array in base16 (hexadecimal).

public static string Base16Encode(this byte[] data)

Parameters

data byte[]

Returns

string

Base32Encode(byte[])

Encodes a byte array in base32 without padding.

public static string Base32Encode(this byte[] data)

Parameters

data byte[]

Returns

string

Base64Utf8Decode(string)

Decodes a UTF-8 in base64 string.

public static string Base64Utf8Decode(this string value)

Parameters

value string

Returns

string

Exceptions

FormatException

value is not a valid base 64 string.

Base64Utf8Encode(string)

Encodes a string as UTF-8 in base64.

public static string Base64Utf8Encode(this string value)

Parameters

value string

Returns

string

Hash(string, HashAlgorithm)

Computes the hash value of a string encoded as UTF-8.

public static string Hash(this string value, HashAlgorithm algorithm)

Parameters

value string
algorithm HashAlgorithm

The hashing algorithm to use.

Returns

string

A hexadecimal string representation of the hash value.

HashSha256(string)

Computes the hash value of a string encoded as UTF-8 using SHA-256.

public static string HashSha256(this string value)

Parameters

value string

Returns

string

A hexadecimal string representation of the hash value.