Skip to content

FROM_BASE64()

Function description

FROM_BASE64() is used to convert Base64-encoded strings back to original binary data (or text data). Data that uses the TO_BASE64() function for Base64 encoding can be decoded. If the parameter is NULL, the result is NULL.

Function Syntax

> FROM_BASE64(str)

Parameter definition

Parameters Description
str Required parameters. Base64 encoded string to be converted.

Example

mysql> select from_base64('MjU1');
+-------------------------+
| from_base64(MjU1) |
+-------------------------+
| 255 |
+-------------------------+
1 row in set (0.00 sec)

mysql> SELECT TO_BASE64('abc'), FROM_BASE64(TO_BASE64('abc'));
+------------------------------------------------------------------------------------------------------------------------------
| to_base64(abc) | from_base64(to_base64(abc)) |
+------------------------------------------------------------------------------------------------------------------------------
| YWJj | abc |
+------------------------------------------------------------------------------------------------------------------------------
1 row in set (0.00 sec)

mysql> select from_base64(null);
+-------------------------+
| from_base64(null) |
+-------------------------+
| NULL |
+-------------------------+
1 row in set (0.01 sec)