SM4_ENCRYPT

description

Syntax

VARCHAR SM4_ENCRYPT(str,key_str[,init_vector])

return encrypted result

example

  1. MySQL > select TO_BASE64(SM4_ENCRYPT('text','F3229A0B371ED2D9441B830D21A390C3'));
  2. +--------------------------------+
  3. | to_base64(sm4_encrypt('text')) |
  4. +--------------------------------+
  5. | aDjwRflBrDjhBZIOFNw3Tg== |
  6. +--------------------------------+
  7. 1 row in set (0.010 sec)
  8. MySQL > set block_encryption_mode="SM4_128_CBC";
  9. Query OK, 0 rows affected (0.001 sec)
  10. MySQL > select to_base64(SM4_ENCRYPT('text','F3229A0B371ED2D9441B830D21A390C3', '0123456789'));
  11. +----------------------------------------------------------------------------------+
  12. | to_base64(sm4_encrypt('text', 'F3229A0B371ED2D9441B830D21A390C3', '0123456789')) |
  13. +----------------------------------------------------------------------------------+
  14. | G7yqOKfEyxdagboz6Qf01A== |
  15. +----------------------------------------------------------------------------------+
  16. 1 row in set (0.014 sec)

keywords

  1. SM4_ENCRYPT

SM4_DECRYPT

description

Syntax

VARCHAR SM4_DECRYPT(str,key_str[,init_vector])

Return the decrypted result

example

  1. MySQL [(none)]> select SM4_DECRYPT(FROM_BASE64('aDjwRflBrDjhBZIOFNw3Tg=='),'F3229A0B371ED2D9441B830D21A390C3');
  2. +------------------------------------------------------+
  3. | sm4_decrypt(from_base64('aDjwRflBrDjhBZIOFNw3Tg==')) |
  4. +------------------------------------------------------+
  5. | text |
  6. +------------------------------------------------------+
  7. 1 row in set (0.009 sec)
  8. MySQL> set block_encryption_mode="SM4_128_CBC";
  9. Query OK, 0 rows affected (0.006 sec)
  10. MySQL > select SM4_DECRYPT(FROM_BASE64('G7yqOKfEyxdagboz6Qf01A=='),'F3229A0B371ED2D9441B830D21A390C3', '0123456789');
  11. +--------------------------------------------------------------------------------------------------------+
  12. | sm4_decrypt(from_base64('G7yqOKfEyxdagboz6Qf01A=='), 'F3229A0B371ED2D9441B830D21A390C3', '0123456789') |
  13. +--------------------------------------------------------------------------------------------------------+
  14. | text |
  15. +--------------------------------------------------------------------------------------------------------+
  16. 1 row in set (0.012 sec)

keywords

  1. SM4_DECRYPT