@robinpath/encode
0.1.1Node.jsPublicEncoding and decoding conversions: Base64, Base32, hex, URL encoding, HTML entities, binary, ROT13, percent-encoding, and more
Encode
Encoding and decoding conversions: Base64, Base32, hex, URL encoding, HTML entities, binary, ROT13, percent-encoding, and more
Package: @robinpath/encode | Category: Utility | Type: Utility
Authentication
No authentication required. All functions are available immediately.
Use Cases
Use the encode module when you need to:
- Encode a string or buffer to Base64 -- Use
encode.base64Encodeto perform this operation - Decode a Base64-encoded string -- Use
encode.base64Decodeto perform this operation - Encode a string to URL-safe Base64 (no padding, +/ replaced with -_) -- Use
encode.base64UrlEncodeto perform this operation - Decode a URL-safe Base64 string -- Use
encode.base64UrlDecodeto perform this operation - Encode a string to hexadecimal representation -- Use
encode.hexEncodeto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
base64Encode | Encode a string or buffer to Base64 | object |
base64Decode | Decode a Base64-encoded string | object |
base64UrlEncode | Encode a string to URL-safe Base64 (no padding, +/ replaced with -_) | object |
base64UrlDecode | Decode a URL-safe Base64 string | object |
hexEncode | Encode a string to hexadecimal representation | object |
hexDecode | Decode a hexadecimal string back to UTF-8 | object |
base32Encode | Encode a string to Base32 (RFC 4648) | object |
base32Decode | Decode a Base32-encoded string | object |
urlEncode | Encode a string using encodeURIComponent | object |
urlDecode | Decode a URL-encoded string using decodeURIComponent | object |
htmlEncode | Encode HTML special characters into entities | object |
htmlDecode | Decode HTML entities back to characters | object |
utf8Encode | Encode a string to an array of UTF-8 byte values | object |
utf8Decode | Decode an array of UTF-8 byte values back to a string | object |
binaryEncode | Encode a string to its binary (0s and 1s) representation | object |
binaryDecode | Decode a binary (0s and 1s) string back to text | object |
asciiToChar | Convert an ASCII code to its character | object |
charToAscii | Convert a character to its ASCII code | object |
rot13 | Apply ROT13 substitution cipher to a string | object |
percentEncode | Percent-encode every byte of a string (e.g. 'A' becomes '%41') | object |
percentDecode | Decode a percent-encoded string | object |
Functions
base64Encode
Encode a string or buffer to Base64
Module: encode | Returns: object -- API response.
encode.base64Encode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The data to encode |
base64Decode
Decode a Base64-encoded string
Module: encode | Returns: object -- API response.
encode.base64Decode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The Base64 string to decode |
base64UrlEncode
Encode a string to URL-safe Base64 (no padding, +/ replaced with -_)
Module: encode | Returns: object -- API response.
encode.base64UrlEncode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The data to encode |
base64UrlDecode
Decode a URL-safe Base64 string
Module: encode | Returns: object -- API response.
encode.base64UrlDecode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The URL-safe Base64 string to decode |
hexEncode
Encode a string to hexadecimal representation
Module: encode | Returns: object -- API response.
encode.hexEncode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The data to encode |
hexDecode
Decode a hexadecimal string back to UTF-8
Module: encode | Returns: object -- API response.
encode.hexDecode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The hex string to decode |
base32Encode
Encode a string to Base32 (RFC 4648)
Module: encode | Returns: object -- API response.
encode.base32Encode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The data to encode |
base32Decode
Decode a Base32-encoded string
Module: encode | Returns: object -- API response.
encode.base32Decode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The Base32 string to decode |
urlEncode
Encode a string using encodeURIComponent
Module: encode | Returns: object -- API response.
encode.urlEncode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The string to URL-encode |
urlDecode
Decode a URL-encoded string using decodeURIComponent
Module: encode | Returns: object -- API response.
encode.urlDecode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The URL-encoded string to decode |
htmlEncode
Encode HTML special characters into entities
Module: encode | Returns: object -- API response.
encode.htmlEncode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The string to encode |
htmlDecode
Decode HTML entities back to characters
Module: encode | Returns: object -- API response.
encode.htmlDecode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The HTML-encoded string to decode |
utf8Encode
Encode a string to an array of UTF-8 byte values
Module: encode | Returns: object -- API response.
encode.utf8Encode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The string to encode |
utf8Decode
Decode an array of UTF-8 byte values back to a string
Module: encode | Returns: object -- API response.
encode.utf8Decode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | array | Yes | Array of byte values |
binaryEncode
Encode a string to its binary (0s and 1s) representation
Module: encode | Returns: object -- API response.
encode.binaryEncode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The string to encode |
separator | string | No | Separator between bytes (default: ' ') |
binaryDecode
Decode a binary (0s and 1s) string back to text
Module: encode | Returns: object -- API response.
encode.binaryDecode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The binary string to decode |
asciiToChar
Convert an ASCII code to its character
Module: encode | Returns: object -- API response.
encode.asciiToChar
| Parameter | Type | Required | Description |
|---|---|---|---|
code | number | Yes | ASCII code (0-127) |
charToAscii
Convert a character to its ASCII code
Module: encode | Returns: object -- API response.
encode.charToAscii
| Parameter | Type | Required | Description |
|---|---|---|---|
char | string | Yes | A single character |
rot13
Apply ROT13 substitution cipher to a string
Module: encode | Returns: object -- API response.
encode.rot13
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The string to transform |
percentEncode
Percent-encode every byte of a string (e.g. 'A' becomes '%41')
Module: encode | Returns: object -- API response.
encode.percentEncode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The string to encode |
percentDecode
Decode a percent-encoded string
Module: encode | Returns: object -- API response.
encode.percentDecode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The percent-encoded string to decode |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
| (standard errors) | Check function parameters and authentication |
@desc "Base64 encode and validate result"
do
set $result as encode.base64Encode
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. Multi-step Encode workflow
Chain multiple encode operations together.
@desc "Base64 encode, base64 decode, and more"
do
set $r_base64Encode as encode.base64Encode
set $r_base64Decode as encode.base64Decode
set $r_base64UrlEncode as encode.base64UrlEncode
print "All operations complete"
enddo
2. Safe base64Encode with validation
Check results before proceeding.
@desc "Base64 encode and validate result"
do
set $result as encode.base64Encode
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
Related Modules
@robinpathv0.1.4
SMTP email sending and address parsing for RobinPath
hash
JS@robinpathv0.1.3
Cryptographic hashing utilities: MD5, SHA family, HMAC, CRC32, file hashing, UUID v5 generation, secure random bytes, and content fingerprinting
csv
JS@robinpathv0.1.2
Parse and stringify CSV data
apollo
JS@robinpathv0.1.2
Apollo module for RobinPath.
$ robinpath add @robinpath/encode
