Liking cljdoc? Tell your friends :D

koine.codec

Base64, portable.

Here rather than in koine.json because it is a host seam, not a pure transform: the JVM has java.util.Base64 and cljgo has cljg.security, and hand-rolling it in clojure.core would be slower and no more portable than either.

Standard base64 with padding (RFC 4648 §4) — NOT the URL-safe alphabet. That is the alphabet MCP image / blob content blocks use, which is what this exists for.

Strings are treated as UTF-8 both ways. encode also accepts a byte array (from koine.fs/read-bytes), which is the case that matters for binary content; decode returns a string and decode-bytes the raw bytes.

Unblocked on cljgo by ADR 0110.

Base64, portable.

Here rather than in `koine.json` because it is a host seam, not a pure
transform: the JVM has `java.util.Base64` and cljgo has `cljg.security`, and
hand-rolling it in `clojure.core` would be slower and no more portable than
either.

Standard base64 with padding (RFC 4648 §4) — NOT the URL-safe alphabet.
That is the alphabet MCP `image` / `blob` content blocks use, which is what
this exists for.

Strings are treated as UTF-8 both ways. `encode` also accepts a byte array
(from `koine.fs/read-bytes`), which is the case that matters for binary
content; `decode` returns a string and `decode-bytes` the raw bytes.

Unblocked on cljgo by ADR 0110.
raw docstring

decodeclj/s

(decode s)

Decode base64 string s to a UTF-8 string. For binary payloads use decode-bytes — a byte that is not valid UTF-8 does not survive this.

Decode base64 string `s` to a UTF-8 string. For binary payloads use
`decode-bytes` — a byte that is not valid UTF-8 does not survive this.
raw docstring

decode-bytesclj/s

(decode-bytes s)

Decode base64 string s to a byte array.

Decode base64 string `s` to a byte array.
raw docstring

encodeclj/s

(encode x)

Base64-encode x — a string (UTF-8) or a byte array. Returns a string.

Base64-encode `x` — a string (UTF-8) or a byte array. Returns a string.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close