Our program demonstrates base64 encoding and decoding in Scheme. Here’s the full source code:
To run the program, save it as base64-encoding.scm and use your Scheme interpreter. For example, if you’re using Chez Scheme:
Note that Scheme doesn’t have built-in base64 encoding/decoding, so we use SRFI 60 for standard base64. For URL-safe base64, we implement custom functions to replace the characters that differ between standard and URL-safe base64 encodings.
The string encodes to slightly different values with the standard and URL-safe base64 encoders (trailing + vs -), but they both decode to the original string as desired.