NodeCrypto Help

Byte Slicer

Category: Utility ยท Node Type ID: utility-slicer

Extracts bytes like the script slice b[offset, length]: empty length = to the end, negative = end position counted from the back (excluded)

Overview

Extracts a contiguous sub-array from the input byte array using the exact same two-argument semantics as the built-in Script byte slice b[offset, length].

Offset specifies the starting byte index (0-based; negative values count backward from the end of the buffer, e.g., -16 starts 16 bytes from the end). Length has three modes depending on its value: if left blank (empty), it slices all the way to the end of the buffer; if ≥ 0, it extracts at most that many bytes; if negative (< 0), it specifies the exclusive end position counted backward from the end of the buffer (for example, Offset = 0, Length = -16 extracts everything except the final 16-byte authentication tag). Both values can be overridden dynamically via the optional Offset and Length input ports.

When to Use

Parameter Configuration

Parameter (ID)Type & DefaultVisibility ConditionDescription & Options
Offset (Start)
offset
number
Default: 0
Supports Variable Reference ($var: int)
Always visible Starting byte index (0-based; negative values count from the end of the input buffer). Overridden at runtime if the Offset input port is connected.
Length
length
text
Default: "" (empty)
Supports Variable Reference ($var: string)
Always visible When blank: slices to the end of the buffer. When ≥ 0: number of bytes to extract. When < 0: exclusive end index counted from the end of the buffer (e.g., -16 stops 16 bytes before the end). Overridden at runtime if the Length input port is connected.

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 NamePort IDData TypeRequiredVisibility ConditionDescription
Data data Bytes Required Always visible Source byte array (Uint8Array) to slice.

Output Ports

Port Nature: Fixed Output Ports (1 total).

Port NamePort IDData TypeVisibility ConditionDescription
Sliced Bytes sliced Bytes Always visible Extracted sub-array (Uint8Array). Out-of-bounds ranges are safely clamped without throwing an error.

Error Cases

When any of the following conditions occurs at runtime, this node transitions to an ERROR state and downstream nodes connected to its outputs do not execute.

Error CodeDefault Engine MessageTrigger Condition
BYTES_OUT_OF_RANGE Index or range is outside the value Raised when a byte or bit index/slice range falls outside the valid bounds of the buffer.
BYTES_INVALID_ARGUMENT Invalid argument value Raised when an argument (such as bit shift count, byte length, or negative integer) is invalid or negative.

Examples

Splitting a Combined (Ciphertext || 16B GCM Tag) Payload

Use two Byte Slicer nodes to separate the ciphertext body from the trailing 16-byte authentication tag.

  1. On the first Byte Slicer (Ciphertext), set Offset to 0 and Length to -16 (extracts from byte 0 up to 16 bytes before the end).
  2. On the second Byte Slicer (Tag), set Offset to -16 and leave Length blank (extracts the last 16 bytes to the end).