NodeCrypto Help

Byte Length

Category: Utility ยท Node Type ID: utility-byte-length

Converts the input to bytes (string = UTF-8, int = minimal length, bool = 1 byte) and returns the byte count

Overview

Computes the byte length of the input value and outputs it as an integer (Int). If the input is already Bytes, it returns data.byteLength directly; otherwise it converts the value using toBytesAuto first (String โ†’ UTF-8 byte count, Int ≥ 0 โ†’ minimal-length byte count where 0 is 1 byte, Bool โ†’ 1 byte).

When to Use

Parameter Configuration

Byte Length requires no configuration parameters.

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
Value in Any Required Always visible

Output Ports

Port Nature: Fixed Output Ports (1 total).

Port NamePort IDData TypeVisibility ConditionDescription
Length length Int Always visible Measured byte count as an integer (Int).

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_INVALID_ARGUMENT Invalid argument value Raised when an argument (such as bit shift count, byte length, or negative integer) is invalid or negative.
BYTES_INT_OVERFLOW The integer cannot be represented with the given length and sign Raised when the integer value cannot fit within the specified fixed or port byte length.

Examples

Prepending a 2-Byte Length Header to a Payload

Measure a payload's byte count, encode it as 2 big-endian bytes, and concatenate.

  1. Connect your payload bytes to Byte Length.
  2. Connect the Length output to Int to Bytes (Fixed length = 2, Big Endian), and concatenate the 2-byte header with the payload in Byte Concatenator.