Photon Fusion 2.0.4

Static Public Member Functions | List of all members
BinUtils Class Reference

Utility class for binary data. More...

Static Public Member Functions

static unsafe String BytesToHex (byte *buffer, int length, int columns=16, string rowSeparator="\n", string columnSeparator=" ")
 Converts a buffer of bytes to a hexadecimal string representation. More...
 
static unsafe string BytesToHex (byte[] buffer, int columns=16)
 Converts a byte array to its hexadecimal string representation. More...
 
static string ByteToHex (byte value)
 Converts a byte value to its hexadecimal string representation. More...
 
static unsafe int HexToBytes (string str, byte *buffer, int length)
 Converts a hexadecimal string to a byte array. More...
 
static unsafe (int, int) HexToInts(string str
 Converts a hexadecimal string to an array of 32-bit integers. More...
 
static unsafe string WordsToHex (int *buffer, int length, int columns=4, string rowSeparator="\n", string columnSeparator=" ")
 Converts a buffer of 32-bit integers to a hexadecimal string representation. More...
 
static unsafe string WordsToHex (uint *buffer, int length, int columns=4, string rowSeparator="\n", string columnSeparator=" ")
 Converts a buffer of 32-bit unsigned integers to a hexadecimal string representation. More...
 

Detailed Description

Utility class for binary data.

Member Function Documentation

◆ BytesToHex() [1/2]

static unsafe String BytesToHex ( byte *  buffer,
int  length,
int  columns = 16,
string  rowSeparator = "\n",
string  columnSeparator = " " 
)
static

Converts a buffer of bytes to a hexadecimal string representation.

Parameters
bufferA pointer to the buffer containing the bytes to convert.
lengthThe number of bytes in the buffer.
columnsThe number of columns to format the output. Default is 16.
rowSeparatorThe string to use as a row separator. Default is newline.
columnSeparatorThe string to use as a column separator. Default is a space.
Returns
A string representing the hexadecimal values of the bytes in the buffer.

◆ BytesToHex() [2/2]

static unsafe string BytesToHex ( byte[]  buffer,
int  columns = 16 
)
static

Converts a byte array to its hexadecimal string representation.

Parameters
bufferThe byte array to convert.
columnsThe number of columns to format the output. Default is 16.
Returns
A string representing the hexadecimal values of the bytes in the array.

◆ ByteToHex()

static string ByteToHex ( byte  value)
static

Converts a byte value to its hexadecimal string representation.

Parameters
valueThe byte value to convert.
Returns
A string representing the hexadecimal value of the byte.

◆ HexToBytes()

static unsafe int HexToBytes ( string  str,
byte *  buffer,
int  length 
)
static

Converts a hexadecimal string to a byte array.

Parameters
strThe hexadecimal string to convert.
bufferA pointer to the buffer where the bytes will be stored.
lengthThe maximum number of bytes to store in the buffer.
Returns
The number of characters processed from the input string.

◆ unsafe()

static unsafe ( int  ,
int   
)
static

Converts a hexadecimal string to an array of 32-bit integers.

Parameters
strThe hexadecimal string to convert.
bufferA pointer to the buffer where the 32-bit integers will be stored.
lengthThe maximum number of 32-bit integers to store in the buffer.
Returns
A tuple containing the number of characters processed from the input string and the number of 32-bit integers stored in the buffer.

◆ WordsToHex() [1/2]

static unsafe string WordsToHex ( int *  buffer,
int  length,
int  columns = 4,
string  rowSeparator = "\n",
string  columnSeparator = " " 
)
static

Converts a buffer of 32-bit integers to a hexadecimal string representation.

Parameters
bufferA pointer to the buffer containing the 32-bit integers to convert.
lengthThe number of 32-bit integers in the buffer.
columnsThe number of columns to format the output. Default is 4.
rowSeparatorThe string to use as a row separator. Default is newline.
columnSeparatorThe string to use as a column separator. Default is a space.
Returns
A string representing the hexadecimal values of the 32-bit integers in the buffer.

◆ WordsToHex() [2/2]

static unsafe string WordsToHex ( uint *  buffer,
int  length,
int  columns = 4,
string  rowSeparator = "\n",
string  columnSeparator = " " 
)
static

Converts a buffer of 32-bit unsigned integers to a hexadecimal string representation.

Parameters
bufferA pointer to the buffer containing the 32-bit unsigned integers to convert.
lengthThe number of 32-bit unsigned integers in the buffer.
columnsThe number of columns to format the output. Default is 4.
rowSeparatorThe string to use as a row separator. Default is newline.
columnSeparatorThe string to use as a column separator. Default is a space.
Returns
A string representing the hexadecimal values of the 32-bit unsigned integers in the buffer.