DEV Community

Discussion on: I'm here to encourage you, ask me anything!

Collapse
 
saikatharryc profile image
Saikat Chakrabortty

Hi Andreas,
Thanks for giving me the opportunity to ask.
so here is the issue:
in Database, all the data are encrypted (e.g User Name and emails as well)
and its good to mention that I'm using MYSQL.
is there any way you can think of or suggest or have an idea, to perform regex search on top of this encrypted data?

for the discussion lets take an example:

Users Table:
UserId | FirstName | LastName |
---|----------|-----------|---
1|4vzrOlgFJ15JVuEwxey6Vw==| 2rqKd00JJEvn0M3HMzuaDg==|
2|4vzrOlgFJ15JVuEwxey6Vw==| 2rqKd00JJEvn0M3HMzuaDg==|

In here say:

For UserId 1, First Name is "Nikole" and UserId 2 is "Nokia",

what I want to achieve is, I would search with "No" and it should give me the UserId 2.
The catch is, I cannot directly search with the keyword, as it's stored in database encrypted.

Thread Thread
 
devmount profile image
Andreas

What encryption do you use?

Thread Thread
 
saikatharryc profile image
Saikat Chakrabortty

aes256 with output_encoding base64 & the secret & Iv key used for this, is again made with pbkdf2Sync with sha512 digest & keylength of 100000.

Thread Thread
 
devmount profile image
Andreas

Got it - well I don't see a way to do it directly in MySQL. You would have to walk through the whole table, decrypt each record and perform your regex search on it...