The base64() function is an SQL function implemented as a loadable extension for SQLite. The function converts a binary BLOB into equivalent RFC 4648 text or converts RFC 4648 text into the equivalent BLOB.
The base64() function is not a standard part of SQLite. It must be loaded as a separate extension. The source code to base64() is in the base64.c source file in the ext/misc/ folder of the SQLite source tree.
The base64() function is not included in standard builds of the SQLite library, but it is loaded by default in the CLI. This is typical of the CLI which loads various extensions above and beyond what are available in the standard SQLite library.
The base64() function always takes a single argument.
If the argument to base64() is a BLOB, then the return value is TEXT that is the RFC 4648 encoding of that BLOB.
If the argument to base64() is base64 TEXT then the return value is a BLOB that is the binary data corresponding to that base64 TEXT.
If the argument to base64() is NULL, then NULL is returned.
An error is raised if the argument to base64() is something other than TEXT, BLOB, or NULL.
If the argument is TEXT, leading and trailing whitespace is ignored.
If the argument is TEXT that has a prefix that looks like base64 but contains non-base64 characters, then as much of the input as possible is translated into a BLOB and that BLOB is returned.
The base64() function uses the standard RFC 4648 alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".
This page last modified on 2024-09-20 17:36:26 UTC