Table of Contents

Class Hex

Namespace
Aptos
Assembly
Aptos.dll

An immutable wrapper around a byte sequence that supports hex parsing / formatting and value-based equality / hashing.

The bytes are defensively copied on construction and on every read so that Hex can safely be used as a key in Dictionary<TKey, TValue> / HashSet<T>: external mutation of the input or returned arrays cannot perturb the instance's hash code or equality. Internal callers that need direct (non-copying) access to the underlying bytes use Aptos.Hex.GetUnsafeByteArrayReference().

[JsonConverter(typeof(HexConverter))]
public class Hex
Inheritance
Hex
Inherited Members

Constructors

Hex(byte[])

public Hex(byte[] data)

Parameters

data byte[]

Methods

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FromHexInput(byte[])

public static Hex FromHexInput(byte[] bytes)

Parameters

bytes byte[]

Returns

Hex

FromHexInput(string)

public static Hex FromHexInput(string input)

Parameters

input string

Returns

Hex

FromHexString(string)

public static Hex FromHexString(string str)

Parameters

str string

Returns

Hex

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

IsValid(string)

public static bool IsValid(string str)

Parameters

str string

Returns

bool

ToByteArray()

Returns a copy of the underlying bytes. Mutating the returned array is safe and will not affect this Hex instance.

public byte[] ToByteArray()

Returns

byte[]

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

ToStringWithoutPrefix()

public string ToStringWithoutPrefix()

Returns

string