PublicShow sourcebase64.pl -- Base64 encoding and decoding

Prolog-based base64 encoding using DCG rules. Encoding according to rfc2045. For example:

1 ?- base64('Hello World', X).

X = 'SGVsbG8gV29ybGQ='

Yes
2 ?- base64(H, 'SGVsbG8gV29ybGQ=').

H = 'Hello World'

The Base64URL encoding provides a URL and file name friendly alternative to base64. Base64URL encoded strings do not contain white space.

author
- Jan Wielemaker
To be done
- Stream I/O
- White-space introduction and parsing
Sourcebase64(+Plain, -Encoded) is det
base64(-Plain, +Encoded) is det
Translates between plaintext and base64 encoded atom or string. See also base64//1.
Sourcebase64url(+Plain, -Encoded) is det
base64url(-Plain, +Encoded) is det
Translates between plaintext and base64url encoded atom or string. Base64URL encoded values can safely be used as URLs and file names. The use "-" instead of "+", "_" instead of "/" and do not use padding. This implies that the encoded value cannot be embedded inside a longer string.
Sourcebase64(+PlainText)// is det
base64(-PlainText)// is det
Encode/decode list of character codes using base64. See also base64/2.
Sourcebase64url(+PlainText)// is det
base64url(-PlainText)// is det
Encode/decode list of character codes using Base64URL. See also base64url/2.