how query on encoded data table in eloquent laravel or php

All the columns (fields) of the table are encoded when saved, how do query(comparison and search tasks).how is this possible? (when i use encodeString() method in laravel just can decode then do something on(in this way if data is big what do) and when use hash method, just can compare it is equal or not like password and can not decode and show).

And is there a better way to protect database information assuming that someone accesses the database?

how can I implement that in laravel or php?

Answer

Solution:

Encryption and Hashing

There are two types of things one is encryption. In that case you give encryption key to encrypt data and same key to decrypt data. If you are using that, you can decrypt data after fetching from DB and compare it.

Other is Hashing. In it your data is hashed by a hashing function. In it data is hashed and its hash will be stored in DB. Passwords are stored in this way. and you cannot get data back from hash. you can create a data hash and compare it with hashes stored in DB.

In other words. Hashing is one way. You can create Hash from data but not data from Hash.

If you use encryption it will increase your system processing too much and if you use Hashing you need to have your data in hands to process it you cannot just retrieve it from DB.

Source