MariaDB starting with 10.0.5

The FROM_BASE64() function was introduced in MariaDB 10.0.5.




Given a base-64 encoded string, returns the decoded result as a binary string.

If str is NULL or an invalid base-64 string, the result is NULL.

TO_BASE64() does the reverse, converting a string to its base-64 equivalent.

There are a numerous different methods to base-64 encode a string. The following are used by MariaDB and MySQL:

  • Alphabet value 64 is encoded as '+'.
  • Alphabet value 63 is encoded as '/'.
  • Encoding output is made up of groups of four printable characters, with each three bytes of data encoded using four characters. If the final group is not complete, it is padded with '=' characters to make up a length of four.
  • To divide long output, a newline is added after every 76 characters.
  • Decoding will recognize and ignore newlines, carriage returns, tabs, and spaces.
SELECT TO_BASE64('Maria');
| TO_BASE64('Maria') |
| TWFyaWE=           |

| FROM_BASE64('TWFyaWE=') |
| Maria                   |


Comments loading...