Choosing an encoding
Base64, hex, URL-encode, percent-encode — which one, when.
Use URL-encoding when the bytes are travelling inside a URL. Spaces become %20, '?' becomes %3F. Never URL-encode binary data — the output will be huge and unreadable.
Use base64 when you have binary bytes and need them in a text channel (email, JSON, HTTP header). Output is ~33% larger than input. If the text channel is a URL, use base64url — it swaps '+' and '/' for '-' and '_' so no further escaping is needed.
Use hex when you want bytes written out by hand or visually diffed. Two characters per byte, always printable. Hex is four times bulkier than raw bytes but nearly twice as compact as base64url for inspecting short values.