4
What kind of encryption should I use to encrypt a CPF in the database and then display that same CPF (decrypted) to the client in a secure manner?
4
What kind of encryption should I use to encrypt a CPF in the database and then display that same CPF (decrypted) to the client in a secure manner?
4
Security is a complex issue, it is not enough to choose a "kind of encryption" and everything will be safe. There are several ways to use the same resource and be safe or not.
Maybe you want to use the mysql encryption if it is this database that you are using. I wouldn’t know which one is best for your case. I could guess that AES_ENCRYPT()
is a good one. I do not know if it would have advantages if doing the work of encryption by PHP.
If you still want to use PHP, you can study mcrypt
. It’s complex and has many options. No one can say which one is right for you.
Of course, showing to the "client" safely involves another problem. The connection needs to be secure. There’s no point in sending this decrypted information. The HTTPS protocol is usually used using the encryption provided by SSL/TLS that is transparent to your application.
But there may still be a problem in the short period in which the data is decrypted on your server. This is usually not considered a major problem because if your server is vulnerable for someone to have access to, the problem is another and it is bigger.
Thanks for the tips buddy. I will study a little and any questions I return aq.
So much AES_ENCRYPT
how much mcrypt
look like good options, the hard part is using them properly. Encrypting in the database itself (option 1) protects the data against the scenario in which the database contents were compromised (an incorrectly discarded backup disk, for example) and maybe help a little against a SQL Injection (if the attacker doesn’t know the key, he can’t inject a command AES_DECRYPT
arbitrary - more yet can change one or another search condition to trick the server by making it decipher more than it should). Option 2 does the same, and a little better (continue..)
The problem is where the key is stored. If it is in a settings file protected by access restrictions (the most common), then a server-controlled attacker could retrieve it. If the key only exists in memory is more difficult, but it is inconvenient to have to enter a password each reboot. These are increasingly unlikely scenarios, but it’s good to keep that in mind when planning a solution. Security is a very contextual topic, as well pointed out at the beginning of the answer: "There are several ways to use the same resource and be safe or not".
Browser other questions tagged php mysql database security-guard cryptography
You are not signed in. Login or sign up in order to post.
Are these Cpfs used to associate people with sensitive information (e.g., financial)? At first glance, it seems a little exaggerated to want to encrypt a number.
– bfavaretto
Unfortunately I need to encrypt the CPF and other friend information.
– Xiro Nakamura
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero