Show / Hide Table of Contents

Class EncodingUtils

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

Inheritance
Object
EncodingUtils
Namespace: NanoByte.Common
Assembly: NanoByte.Common.dll
Syntax
public static class EncodingUtils : Object

Fields

Utf8

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

Declaration
public static readonly Encoding Utf8
Field Value
Type Description
Encoding

Methods

Base16Decode(String)

Decodes a base16 (hexadecimal) to a byte array.

Declaration
public static byte[] Base16Decode(this string encoded)
Parameters
Type Name Description
String encoded
Returns
Type Description
Byte[]

Base16Encode(Byte[])

Encodes a byte array in base16 (hexadecimal).

Declaration
public static string Base16Encode(this byte[] data)
Parameters
Type Name Description
Byte[] data
Returns
Type Description
String

Base32Encode(Byte[])

Encodes a byte array in base32 without padding.

Declaration
public static string Base32Encode(this byte[] data)
Parameters
Type Name Description
Byte[] data
Returns
Type Description
String

Base64Utf8Decode(String)

Decodes a UTF-8 in base64 string.

Declaration
public static string Base64Utf8Decode(this string value)
Parameters
Type Name Description
String value
Returns
Type Description
String
Exceptions
Type Condition
FormatException

value is not a valid base 64 string.

Base64Utf8Encode(String)

Encodes a string as UTF-8 in base64.

Declaration
public static string Base64Utf8Encode(this string value)
Parameters
Type Name Description
String value
Returns
Type Description
String

Hash(String, HashAlgorithm)

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

Declaration
public static string Hash(this string value, HashAlgorithm algorithm)
Parameters
Type Name Description
String value

The string to hash.

HashAlgorithm algorithm

The hashing algorithm to use.

Returns
Type Description
String

A hexadecimal string representation of the hash value.

In This Article
Back to top Copyright Bastian Eicher