Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: security and speed of AES_DECRYPT with LIKE

I have 55000 records in a table where the keyval (varchar) column contains 15 character long strings encrypted with AES_ENCRYPT. I tried a LIKE query on this column and was surprised to see that it answers very quickly. How is that possible? My guess is that it uses the column index somehow but doesn't that mean that the index is insecure?

select aes_decrypt(keyval,'secret') from `table` WHERE aes_decrypt(keyval,'secret') like '%abc%'
Showing rows 0 - 2 ( 3 total, Query took 0.0644 sec)
...
like image 421
Arthur Avatar asked Oct 20 '25 10:10

Arthur


1 Answers

AES is fast. Look at http://www.cryptopp.com/benchmarks.html - on old hardware, AES can process 100Mb/sec.

So 55k rows x 15 bytes per row = 825Kb, which should take no time at all.

So there is nothing to worry about.

like image 186
artbristol Avatar answered Oct 22 '25 00:10

artbristol