Stdlib: Base64 and Hex encoding builtins #246

Closed
opened 2026-01-12 02:36:47 +00:00 by navicore · 1 comment
navicore commented 2026-01-12 02:36:47 +00:00 (Migrated from github.com)

Summary

Add encoding/decoding utilities for Base64 and hexadecimal. These are commonly needed alongside crypto operations, for data serialization, and URL-safe encoding.

Proposed API

# Base64 encoding/decoding
data encoding.base64-encode       # ( String -- String )
encoded encoding.base64-decode    # ( String -- String Bool ) Bool=success

# URL-safe Base64 (for JWTs, URLs)
data encoding.base64url-encode    # ( String -- String )
encoded encoding.base64url-decode # ( String -- String Bool )

# Hex encoding/decoding
bytes encoding.hex-encode         # ( Bytes -- String )
hex encoding.hex-decode           # ( String -- Bytes Bool )

Implementation

FFI wrappers around:

  • base64 crate
  • Standard library hex encoding or hex crate

Estimated effort: 1 day

Deliverables Checklist

  • Runtime builtins in crates/runtime/src/
  • Unit tests for each function
  • Integration tests in tests/integration/src/test-encoding.seq
  • LSP support: signatures in BUILTIN_SIGNATURES, docs in BUILTIN_DOCS
  • Example: examples/encoding/base64-demo.seq
  • Update docs/BATTERIES_INCLUDED.md status

Use Cases Unlocked

  • JWT encoding/decoding
  • Binary data in JSON
  • Crypto output formatting
  • URL-safe data transmission
  • Debug output for binary data

References

  • See docs/BATTERIES_INCLUDED.md Priority 4: Cryptography (encoding helpers section)
## Summary Add encoding/decoding utilities for Base64 and hexadecimal. These are commonly needed alongside crypto operations, for data serialization, and URL-safe encoding. ## Proposed API ```seq # Base64 encoding/decoding data encoding.base64-encode # ( String -- String ) encoded encoding.base64-decode # ( String -- String Bool ) Bool=success # URL-safe Base64 (for JWTs, URLs) data encoding.base64url-encode # ( String -- String ) encoded encoding.base64url-decode # ( String -- String Bool ) # Hex encoding/decoding bytes encoding.hex-encode # ( Bytes -- String ) hex encoding.hex-decode # ( String -- Bytes Bool ) ``` ## Implementation FFI wrappers around: - `base64` crate - Standard library hex encoding or `hex` crate Estimated effort: 1 day ## Deliverables Checklist - [ ] Runtime builtins in `crates/runtime/src/` - [ ] Unit tests for each function - [ ] Integration tests in `tests/integration/src/test-encoding.seq` - [ ] LSP support: signatures in `BUILTIN_SIGNATURES`, docs in `BUILTIN_DOCS` - [ ] Example: `examples/encoding/base64-demo.seq` - [ ] Update `docs/BATTERIES_INCLUDED.md` status ## Use Cases Unlocked - JWT encoding/decoding - Binary data in JSON - Crypto output formatting - URL-safe data transmission - Debug output for binary data ## References - See `docs/BATTERIES_INCLUDED.md` Priority 4: Cryptography (encoding helpers section)
navicore commented 2026-01-12 03:21:21 +00:00 (Migrated from github.com)
https://github.com/navicore/patch-seq/pull/253
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
navicore/patch-seq#246
No description provided.