method
Crypto.base64
Crypto.base64(s) -> string
Encodes the bytes of s as standard base64 (RFC 4648, the A–Z a–z 0–9 + / alphabet with = padding). Base64 turns arbitrary bytes into printable ASCII, which is what you want when a digest, key, or binary blob has to travel through a text-only channel — a JSON field, a URL-safe token wrapper, a config file, a log line. It is an *encoding*, not encryption: it hides nothing and adds no integrity. Pair it with Crypto.hmac_sha256 when the payload must also be tamper-evident.
The output length is always a multiple of four; a one- or two-byte remainder in the input is padded with =.
Parameters
sthe string whose bytes are encodedExample
program Encode {
entry {
print(Crypto.base64("foobar")) # Zm9vYmFy
print(Crypto.base64("f")) # Zg==
}
}