Show / Hide Table of Contents

Class Hex

Helper class for converting between bytes and Hex encoded string values.

Inheritance
object
Hex
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class Hex

Methods

| Edit this page View Source

FromBytes(byte[])

Converts a blob of bytes into the corresponding hex encoded string.

Declaration
public static string FromBytes(byte[] bytes)
Parameters
Type Name Description
byte[] bytes

Blob of bytes to turn into Hex.

Returns
Type Description
string

String value of the bytes in lowercase Hex.

| Edit this page View Source

FromBytes(ReadOnlyMemory<byte>)

Converts a blob of bytes into the corresponding hex encoded string.

Declaration
public static string FromBytes(ReadOnlyMemory<byte> bytes)
Parameters
Type Name Description
ReadOnlyMemory<byte> bytes

Blob of bytes to turn into Hex.

Returns
Type Description
string

String value of the bytes in lowercase Hex.

| Edit this page View Source

FromBytes(ReadOnlySpan<byte>)

Converts a blob of bytes into the corresponding hex encoded string, using a ReadOnlySpan for performance.

Declaration
public static string FromBytes(ReadOnlySpan<byte> bytes)
Parameters
Type Name Description
ReadOnlySpan<byte> bytes

Blob of bytes to turn into Hex.

Returns
Type Description
string

String value of the bytes in lowercase Hex.

| Edit this page View Source

ToBytes(string)

Converts string values encoded in Hex into bytes.

Declaration
public static ReadOnlyMemory<byte> ToBytes(string hex)
Parameters
Type Name Description
string hex

A string containing a series of characters in hexadecimal format.

Returns
Type Description
ReadOnlyMemory<byte>

A blob of bytes decoded from the hex string.

Exceptions
Type Condition
ArgumentNullException

If the input string is

null

.

ArgumentOutOfRangeException

If the string of characters is not valid Hex.

| Edit this page View Source

TryDecode(ReadOnlySpan<char>, Span<byte>, out int)

Parses a hex encoded string into a byte array.

Declaration
public static bool TryDecode(ReadOnlySpan<char> hex, Span<byte> buffer, out int bytesWritten)
Parameters
Type Name Description
ReadOnlySpan<char> hex

The Hex Value

Span<byte> buffer

Span receiving the decoded bytes

int bytesWritten

Number of bytes written into the span

Returns
Type Description
bool

true if successful, false if the hex string is invalid or buffer is too small.

| Edit this page View Source

TryEncode(ReadOnlySpan<byte>, Span<char>, out int)

Computes the hex representation of a byte array and writes it to a destination span.

Declaration
public static bool TryEncode(ReadOnlySpan<byte> bytes, Span<char> destination, out int charsWritten)
Parameters
Type Name Description
ReadOnlySpan<byte> bytes

Incoming Bytes

Span<char> destination

Span that will Receive the lower case encoded hex char values

int charsWritten

Number of characters written (in case the buffer is larger than needed)

Returns
Type Description
bool
  • Edit this page
  • View Source
In this article
Back to top .NET Client Library for Hiero Network and Hedera Hashgraph