Implementation of standard Base64 encoding.
Variation of Base64 encoding that is safe for use in URLs and filenames.
Unpadded variation of Base64 encoding that is safe for use in URLs and filenames, as used in RFCs 4648 and 7515 (JWS/JWT/JWE).
Exception thrown upon encountering Base64 encoding or decoding errors.
Template for implementing Base64 encoding and decoding.
ubyte[] data = [0x14, 0xfb, 0x9c, 0x03, 0xd9, 0x7e]; const(char)[] encoded = Base64.encode(data); assert(encoded == "FPucA9l+"); ubyte[] decoded = Base64.decode("FPucA9l+"); assert(decoded == [0x14, 0xfb, 0x9c, 0x03, 0xd9, 0x7e]);
The range API is supported for both encoding and decoding:
// Create MIME Base64 with CRLF, per line 76. File f = File("./text.txt", "r"); scope(exit) f.close(); Appender!string mime64 = appender!string; foreach (encoded; Base64.encoder(f.byChunk(57))) { mime64.put(encoded); mime64.put("\r\n"); } writeln(mime64.data);
References: RFC 4648 - The Base16
Masahiro Nakagawa 2010-.
Support for Base64 encoding and decoding.
This module provides two default implementations of Base64 encoding, Base64 with a standard encoding alphabet, and a variant Base64URL that has a modified encoding alphabet designed to be safe for embedding in URLs and filenames.
Both variants are implemented as instantiations of the template Base64Impl. Most users will not need to use this template directly; however, it can be used to create customized Base64 encodings, such as one that omits padding characters, or one that is safe to embed inside a regular expression.