user3565145
user3565145

Reputation:

Using MySQL LIKE or = Operators to Select Encrypted Data

I've found this Rijndael 256-bit Encryption (CBC) Class for encrypt/decrypt some information in my MySQL Server and it was useful, but how can I select this encrypted data with 'LIKE' or '=' operators?

For example:

'SELECT name from tblx WHERE name = "'.$crypt->encrypt('George').'"';

or:

'SELECT name from tblx WHERE name LIKE "'.$crypt->encrypt('Geo').'%"';

Upvotes: 1

Views: 154

Answers (1)

Scott Arciszewski
Scott Arciszewski

Reputation: 34093

I recommend reading through this guide to searchable encryption (mirror). It steps through a lot of insecure solutions to this problem (non-randomized encryption) and eventually builds up to a secure solution.

The secure solution was implemented in an open source library called CipherSweet.

Upvotes: 1

Related Questions