String to Bytes
Encodes text string into raw byte array using specified charset
Overview
Encodes a text string into a raw byte array (Uint8Array) using the selected character encoding (utf-8, ascii, or latin1 / ISO-8859-1).
Because cryptographic primitives (ciphers, hashes, MACs, and digital signatures) operate on exact byte sequences rather than abstract Unicode strings, use this node whenever you want to encrypt, hash, or sign human-readable text.
When to Use
- Converting plaintext messages, passphrases, HKDF info strings, or AEAD Additional Authenticated Data (AAD) from
StringintoBytes. - Encoding ASCII or Latin-1 protocol headers into exact byte arrays.
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Character Encodingencoding |
selectDefault: utf-8 |
Always visible | Character encoding used to serialize the string: utf-8 (variable-width 1–4 bytes per code point), ascii (low 7 bits per character), or latin1 (low 8 bits per character 0x00..0xFF).
|
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 |
|---|---|---|---|---|---|
String In |
string |
String |
Required | Always visible | Input text string to encode. |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Bytes Out |
bytes |
Bytes |
Always visible | Encoded byte array (Uint8Array). |
Error Cases
This node has no runtime failure cases (errorProfile: none) and always succeeds for any valid typed input.
Examples
Encoding a UTF-8 Message for Hashing or Encryption
Convert a text string into bytes before feeding it to SHA-256.
- Connect a
Stringsource to String to Bytes (Character Encoding = UTF-8). - Connect the
Bytesoutput port to theDatainput port of Hash Digest.