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
databyte[]
Methods
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
FromHexInput(byte[])
public static Hex FromHexInput(byte[] bytes)
Parameters
bytesbyte[]
Returns
FromHexInput(string)
public static Hex FromHexInput(string input)
Parameters
inputstring
Returns
FromHexString(string)
public static Hex FromHexString(string str)
Parameters
strstring
Returns
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
strstring
Returns
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()