Bytes to Int
Interprets bytes as an unsigned integer (bigint when beyond the safe range)
Overview
Interprets a raw byte array (Uint8Array) of any length as an unsigned integer (Int / bigint) according to the selected Endian byte order (Big-Endian or Little-Endian). An empty (0-byte) input buffer evaluates to 0.
Because NodeCrypto represents Int values at runtime using arbitrary-precision bigint when values exceed the 53-bit JavaScript safe integer limit, this node can losslessly decode 128-bit counters, 256-bit hashes, or 2048-bit RSA moduli into integers.
When to Use
- Parsing length fields, sequence numbers, or integer headers extracted by a Byte Slicer node.
- Converting binary keys, nonces, or digests into integers for arithmetic in a Script node or comparison in Compare.
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Endianendian |
selectDefault: big |
Always visible | Byte order used to interpret the input buffer: big (first byte is most significant) or little (first byte is least significant).
|
Port I/O Specification
See Ports & Connections for general wiring rules, data type colors, and dynamic port creation.
Input Ports
Port Nature: Fixed Input Ports (1 total).
| Port Name | Port ID | Data Type | Required | Visibility Condition | Description |
|---|---|---|---|---|---|
Bytes |
in |
Bytes |
Required | Always visible |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Value |
out |
Int |
Always visible |
Error Cases
This node has no runtime failure cases (errorProfile: none) and always succeeds for any valid typed input.
Examples
Reading a 2-Byte Big-Endian Length Header
Slice the first 2 bytes of a packet and decode them as an integer length.
- Use Byte Slicer (
Offset = 0,Length = 2) to extract the header bytes. - Connect the slice to Bytes to Int with Endian set to
Big Endian.