百度智能云

All Product Document

          Data Warehouse

          Format Conversion Function

          The conversion functions of Palo format are as follows:

          1.aes_encrypt
          2.aes_decrypt
          3.to_base64
          4.from_base64
          5.md5,md5sum

          AES_ENCRYPT

          Description

          aes_encrypt(string str, string key)
          • Function: Use key to encrypt str and return the encrypted result. This function uses AES algorithm to encrypt a given string with a key length of 128 bits, and locks the encrypted string with the password given in the second parameter. If one of the given parameters is null, the function will return a null value.
          • Return type: string type

          Example

          Due to the problems with the display of encrypted characters, here we use HEX() function to encode the encrypted character string in hexadecimal system, and then extract it with UNHEX() when decrypting.

          mysql> select hex(aes_encrypt("Palo is Great", "baidu"));
          +--------------------------------------------+
          | hex(aes_encrypt('Palo is Great', 'baidu')) |
          +--------------------------------------------+
          | 676EC1EDBB586B736A23257E0ED78C17           |
          +--------------------------------------------+

          Keywords

          aes_encrypt

          AES_DECRYPT

          Description

          aes_decrypt(string str, string key)
          • Function: use key to decrypt str, and return the decrypted result
          • Return type: string type

          Example

          Decrypt the encrypted string with aes_decrypt, first extract the hexadecimal code with UNHEX (), and then decrypt it with decryption function.

          mysql> select aes_decrypt(unhex('676EC1EDBB586B736A23257E0ED78C17'),'baidu');
          +-----------------------------------------------------------------+
          | aes_decrypt(unhex('676EC1EDBB586B736A23257E0ED78C17'), 'baidu') |
          +-----------------------------------------------------------------+
          | Palo is Great                                                   |
          +-----------------------------------------------------------------+

          Keywords

          aes_decrypt

          TO_BASE64

          Description

          to_base64(string str)
          • Function: convert str to base64 format and return the result of base64
          • Return type: string type

          Example

          mysql> select to_base64('palo');
          +-------------------+
          | to_base64('palo') |
          +-------------------+
          | cGFsbw==          |
          +-------------------+

          Keywords

          to_base64

          FROM_BASE64

          Description

          from_base64(string str)
          • Function: decrypt str in base64 format and return the decrypted result.
          • Return type: string type

          Example

          mysql> select from_base64('cGFsbw==');
          +-------------------------+
          | from_base64('cGFsbw==') |
          +-------------------------+
          | palo                    |
          +-------------------------+

          Keywords

           from_base64

          MD5, MD5SUM

          Description

          md5(string str)
          
          md5sum(string str)
          • Function: convert str to md5 format and return the result of md5
          • Return type: string type

          Example

          mysql> select md5('palo');
          +----------------------------------+
          | md5('palo')                      |
          +----------------------------------+
          | b50347c6fa8e55d5b562fe0f1511d324 |
          +----------------------------------+
          
          mysql> select md5sum('palo');
          +----------------------------------+
          | md5sum('palo')                   |
          +----------------------------------+
          | b50347c6fa8e55d5b562fe0f1511d324 |
          +----------------------------------+

          Keywords

          md5, md5sum
          Previous
          BITMAP Function
          Next
          Time and Date Function