Monday, 24 September 2018

MySQL TO_BASE64(str) function

TO_BASE64 function in mysql is used for encode any string with the string encode rule BASE64. This function returns a encoded string. This function is added with the mysql version 5.6.1
In mysql there is different base-64 encoding schemes exist. These are the encoding and decoding rules used by TO_BASE64() and FROM_BASE64():
-> The encoding for alphabet value 62 is '+'.
-> The encoding for alphabet value 63 is '/'.
-> Encoded output consists of groups of 4 printable characters. Each 3 bytes of the input data are encoded using 4 characters. If the last group is incomplete, it is padded with '=' characters to a length of 4.
-> A newline is added after each 76 characters of encoded output to divide long output into multiple lines.
-> Decoding recognizes and ignores newline, carriage return, tab, and space.
Here is a example in which I encode a sring by BASE64 encoding rule-
  1. mysql> SELECT TO_BASE64('base64 encoded string');
  2. -> YmFzZTY0IGVuY29kZWQgc3RyaW5n

0 comments:

Post a Comment