We have developed a mobile app which uses mobile phone number and otp for authentication. Since phone number is part of sensitive user information, we have to encrypt or hash it to reduce the risk of exposing users sensitive data in case of leak.
When a user logs in, after otp, I have to fetch the user information from db and for that purpose, I have to run a query to match against the users phones in database. The encryption works fine as I can decrypt the phone and then match against the login phone number. However, due to large number of users, this is slower
Another option for me is to hash the phone numbers. then I can hash the login phone number against the hashed phone in the database. However, since same phone number will not generate the same hash, comparing is not possible
Another way is to use the Hash check function but that can be used alone when you single value of login phone against a single row fetched from the database.
I would like to know if the hash matching can be used in the laravel query so that the hashed login user phone numbers is checked against the hashed phone numbers in the database.
I would appreciate if someone can give me a solution for this.
Regards