I would like to store email addresses in a database but as it is a shared one, I would like to store them crypted and decrypted when needed.
I thought of Encrypting the first part of it (before the @) so i come up with something like this:
Real email: myemail@gmail.com
Encrypted desired : 4n095tOA8PpRq5Nw2tIEp8l47@gmail.com
The proble is that when I use a function like this :
function EncryptVar($sVar){
return openssl_encrypt($sVar, $this->encryptionMethod, $this->secretHash);
}
with some secret hash and this following method
$this->secretHash = "25c6c7ff35b9979b151f2136cd1sdftrez";
$this->encryptionMethod = "AES-256-CBC";
I may come up with special characters in the encrypted part, therefore an invalid email address format.
Is there a way to use this method so I have only letters and digits?