NanoByte.Common  2.10.5
NanoByte.Common.EncodingUtils Class Reference

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

Static Public Member Functions

static string Hash (this string value, HashAlgorithm algorithm)
 Computes the hash value of a string encoded as UTF-8. More...
 
static string Base64Utf8Encode (this string value)
 Encodes a string as UTF-8 in base64. More...
 
static string Base64Utf8Decode (this string value)
 Decodes a UTF-8 in base64 string. More...
 
static string Base32Encode (this byte[] data)
 Encodes a byte array in base32 without padding. More...
 
static string Base16Encode (this byte[] data)
 Encodes a byte array in base16 (hexadecimal). More...
 
static byte[] Base16Decode (this string encoded)
 Decodes a base16 (hexadecimal) to a byte array. More...
 

Static Public Attributes

static readonly Encoding Utf8 = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)
 UTF-8 encoding without BOM (byte order marker). More...
 

Detailed Description

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

Member Function Documentation

◆ Base16Decode()

static byte [] NanoByte.Common.EncodingUtils.Base16Decode ( this string  encoded)
inlinestatic

Decodes a base16 (hexadecimal) to a byte array.

◆ Base16Encode()

static string NanoByte.Common.EncodingUtils.Base16Encode ( this byte[]  data)
inlinestatic

Encodes a byte array in base16 (hexadecimal).

◆ Base32Encode()

static string NanoByte.Common.EncodingUtils.Base32Encode ( this byte[]  data)
inlinestatic

Encodes a byte array in base32 without padding.

◆ Base64Utf8Decode()

static string NanoByte.Common.EncodingUtils.Base64Utf8Decode ( this string  value)
static

Decodes a UTF-8 in base64 string.

Exceptions
FormatExceptionvalue is not a valid base 64 string.

◆ Base64Utf8Encode()

static string NanoByte.Common.EncodingUtils.Base64Utf8Encode ( this string  value)
static

Encodes a string as UTF-8 in base64.

◆ Hash()

static string NanoByte.Common.EncodingUtils.Hash ( this string  value,
HashAlgorithm  algorithm 
)
inlinestatic

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

Parameters
valueThe string to hash.
algorithmThe hashing algorithm to use.
Returns
A hexadecimal string representation of the hash value.

Member Data Documentation

◆ Utf8

readonly Encoding NanoByte.Common.EncodingUtils.Utf8 = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)
static

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


The documentation for this class was generated from the following file: