Nyx Node
Loading...
Searching...
No Matches
Nyx utilities

Nyx utilities. More...

Functions

int nyx.utils.nyx_hash (str|bytes|None string, int seed)
 Hashes a string using the MurmurHash2 algorithm.
bytes nyx.utils.nyx_generate_mac_addr (int mac0, int mac1, str node_id)
 Generates a MAC address based on a node identifier.
str|None nyx.utils.nyx_base64_encode (bytes|None data)
 Encodes a buffer using the Base64 algorithm.
bytes|None nyx.utils.nyx_base64_decode (str|None data)
 Decodes a string using the Base64 algorithm.

Detailed Description

Nyx utilities.

Function Documentation

◆ nyx_hash()

int nyx_hash ( str | bytes | None string,
int seed )

Hashes a string using the MurmurHash2 algorithm.

Parameters
stringString to hash.
seedInitial seed value.
Returns
The computed 32-bit hash.

Definition at line 22 of file utils.py.

◆ nyx_generate_mac_addr()

bytes nyx_generate_mac_addr ( int mac0,
int mac1,
str node_id )

Generates a MAC address based on a node identifier.

Parameters
mac0First fixed byte of the MAC address.
mac1Second fixed byte of the MAC address.
node_idUnique node identifier used to hash the remaining bytes.
Returns
The generated MAC address.

Definition at line 44 of file utils.py.

◆ nyx_base64_encode()

str | None nyx_base64_encode ( bytes | None data)

Encodes a buffer using the Base64 algorithm.

Parameters
dataData to encode.
Returns
The encoded string, or None when no data is provided.

Definition at line 74 of file utils.py.

◆ nyx_base64_decode()

bytes | None nyx_base64_decode ( str | None data)

Decodes a string using the Base64 algorithm.

Parameters
dataBase64 data to decode.
Returns
The decoded buffer, or None when no data is provided.

Definition at line 101 of file utils.py.