Class ByteUtil
Utility methods to deal with
Namespace: Libplanet
Assembly: Libplanet.dll
Syntax
public static class ByteUtil : object
Methods
| Improve this Doc View SourceCalculateHashCode(Byte[])
Calculates a deterministic hash code from a given
bytes
. It is mostly used to implement
Declaration
public static int CalculateHashCode(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | bytes | A |
Returns
Type | Description |
---|---|
Int32 | A hash code determined from the given
|
Hex(in ImmutableArray<Byte>)
Renders a hexadecimal string from a
Declaration
public static string Hex(in ImmutableArray<byte> bytes)
Parameters
Type | Name | Description |
---|---|---|
ImmutableArray<Byte> | bytes | A |
Returns
Type | Description |
---|---|
String | A hexadecimal string which encodes the given
|
Hex(Byte[])
Renders a hexadecimal string from a
Declaration
public static string Hex(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | bytes | A |
Returns
Type | Description |
---|---|
String | A hexadecimal string which encodes the given
|
ParseHex(String)
Converts a hexadecimal string to a
Declaration
public static byte[] ParseHex(string hex)
Parameters
Type | Name | Description |
---|---|---|
String | hex | A |
Returns
Type | Description |
---|---|
Byte[] | A |
Satisfies(IReadOnlyList<Byte>, Int64)
Tests if a hash digest is less than the target computed for the given
difficulty
).
Declaration
public static bool Satisfies(IReadOnlyList<byte> hashDigest, long difficulty)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<Byte> | hashDigest | A hash digest to test. |
Int64 | difficulty | The difficulty to compute target number. |
Returns
Type | Description |
---|---|
Boolean |
|
TimingSafelyCompare(IReadOnlyList<Byte>, IReadOnlyList<Byte>)
Timing safe comparision of two byte arrays.
Declaration
public static bool TimingSafelyCompare(IReadOnlyList<byte> left, IReadOnlyList<byte> right)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<Byte> | left | A byte array. |
IReadOnlyList<Byte> | right | Another byte array. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
In case of two byte arrays do not have the same length, it tries to keep the timing dependent on the length of the shorter one.