AES_ENCRYPT

description

encryption of data using the official AES

Syntax

VARCHAR AES_ENCRYPT(str,key_str[,init_vector])

example

  1. MySQL > select to_base64(AES_ENCRYPT('text','F3229A0B371ED2D9441B830D21A390C3'));
  2. +--------------------------------+
  3. | to_base64(aes_encrypt('text')) |
  4. +--------------------------------+
  5. | wr2JEDVXzL9+2XtRhgIloA== |
  6. +--------------------------------+
  7. 1 row in set (0.010 sec)
  8. MySQL> set block_encryption_mode="AES_256_CBC";
  9. Query OK, 0 rows affected (0.006 sec)
  10. MySQL > select to_base64(AES_ENCRYPT('text','F3229A0B371ED2D9441B830D21A390C3', '0123456789'));
  11. +----------------------------------------------------------------------------------+
  12. | to_base64(aes_encrypt('text', 'F3229A0B371ED2D9441B830D21A390C3', '0123456789')) |
  13. +----------------------------------------------------------------------------------+
  14. | mvZT1KJw7N0RJf27aipUpg== |
  15. +----------------------------------------------------------------------------------+
  16. 1 row in set (0.011 sec)

AES_DECRYPT

description

decryption of data using the official AES (### Syntax

VARCHAR AES_DECRYPT(str,key_str[,init_vector])

example

  1. MySQL > select AES_DECRYPT(FROM_BASE64('wr2JEDVXzL9+2XtRhgIloA=='),'F3229A0B371ED2D9441B830D21A390C3');
  2. +------------------------------------------------------+
  3. | aes_decrypt(from_base64('wr2JEDVXzL9+2XtRhgIloA==')) |
  4. +------------------------------------------------------+
  5. | text |
  6. +------------------------------------------------------+
  7. 1 row in set (0.012 sec)
  8. MySQL> set block_encryption_mode="AES_256_CBC";
  9. Query OK, 0 rows affected (0.006 sec)
  10. MySQL > select AES_DECRYPT(FROM_BASE64('mvZT1KJw7N0RJf27aipUpg=='),'F3229A0B371ED2D9441B830D21A390C3', '0123456789');
  11. +--------------------------------------------------------------------------------------------------------+
  12. | aes_decrypt(from_base64('mvZT1KJw7N0RJf27aipUpg=='), 'F3229A0B371ED2D9441B830D21A390C3', '0123456789') |
  13. +--------------------------------------------------------------------------------------------------------+
  14. | text |
  15. +--------------------------------------------------------------------------------------------------------+
  16. 1 row in set (0.012 sec)

keyword

  1. AES_ENCRYPT, AES_DECRYPT