namespaces

base64

Encode text to base64 and decode it back, with an optional URL-safe alphabet.

The base64 namespace encodes text to base64 and decodes it back. Pass url_safe: true for the URL and filename safe alphabet, used in tokens and query values.

Operations

marreta
encoded = base64.encode(text)
back = encoded >> base64.decode() rescue null
NameSignatureSummary
base64.encodebase64.encode(text, url_safe: true)Encodes text as base64.
base64.decodebase64.decode(text, url_safe: true)Decodes base64 text.

Notes

  • base64.decode fails on input that is not valid base64. Wrap it in rescue when the input is untrusted.