Skip to main content

Module base64

Module base64 

Source
Expand description

Base64, in both alphabets this crate needs.

APP_KEY is written the way an operator expects to see it — standard alphabet, padded, exactly what openssl rand -base64 32 prints. Encrypted payloads and signatures travel in cookies and query strings, so they use the URL-safe alphabet with no padding and need no percent-encoding at all.

Fifty lines is cheaper than a dependency, and getting base64 wrong is visible immediately, unlike getting a cipher wrong.

Functions§

decode
Decode either alphabet, with or without padding.
encode
Standard alphabet, padded with =.
encode_url
URL-safe alphabet, unpadded — safe in a cookie value or a query string.