MySQL Symmetric Encryption: Difference between revisions
From Lolly's Wiki
Jump to navigationJump to search
m (Text replacement - "<source" to "<syntaxhighlight") |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category:MySQL]] | |||
<syntaxhighlight lang=mysql> | <syntaxhighlight lang=mysql> | ||
> select hex(aes_encrypt(rpad("abcqweqweqweqwe",31,"~"),"mykey")) as encrypted; | > select hex(aes_encrypt(rpad("abcqweqweqweqwe",31,"~"),"mykey")) as encrypted; | ||
Line 7: | Line 7: | ||
| E5FB394568B8F03D43CF083F5065C959AC6E22BDB7749E4D97F5ABC72B08D843 | | | E5FB394568B8F03D43CF083F5065C959AC6E22BDB7749E4D97F5ABC72B08D843 | | ||
+------------------------------------------------------------------+ | +------------------------------------------------------------------+ | ||
</ | </syntaxhighlight> | ||
<syntaxhighlight lang=mysql> | <syntaxhighlight lang=mysql> | ||
Line 16: | Line 16: | ||
| abcqweqweqweqwe | | | abcqweqweqweqwe | | ||
+-----------------+ | +-----------------+ | ||
</ | </syntaxhighlight> |
Latest revision as of 09:58, 26 November 2021
> select hex(aes_encrypt(rpad("abcqweqweqweqwe",31,"~"),"mykey")) as encrypted;
+------------------------------------------------------------------+
| encrypted |
+------------------------------------------------------------------+
| E5FB394568B8F03D43CF083F5065C959AC6E22BDB7749E4D97F5ABC72B08D843 |
+------------------------------------------------------------------+
> select trim(trailing "~" from aes_decrypt(unhex("E5FB394568B8F03D43CF083F5065C959AC6E22BDB7749E4D97F5ABC72B08D843"),"mykey")) as decrypted;
+-----------------+
| decrypted |
+-----------------+
| abcqweqweqweqwe |
+-----------------+