Hướng dẫn php pdo encryption
Insert Data with the PDO: From the snippet below you can see that the PDO is quite similar to the fashion with which you create parameters in .NET and SQL. Here, the columns are specified in the prepare statement and the placeholders (like :columnA) is where the data is ultimately put which you are passing. With bindParam -> PDO::PARAM_INT (or PDO::PARAM_STR), those are optional to use in most cases. $columnA = 1; Insert Data with the PDO and AES Encryption: Performing an insert with AES encryption is straight-forward as shown below. The column which will hold the encrypted data must be a blob (binary data). The encryption key resides only in your PHP code (it is not saved into the mySQL database) so if your mySQL database is compromised that does not necessarily mean the encrypted data in it is compromised because the key is not there. $columnA = 1; Updating Data with the PDO: An update is similar to an insert with the PDO. Check it out. $rowNumber = 1; Updating Data with the PDO and AES Encryption: And, an update with AES encryption is straight-forward as you can see.
$rowNumber = 1; Selecting Data with the PDO: Getting data from mySQL and the PDO is slightly different than what we've covered so far. To keep things similar with traditional mySQL, I've set the fetch mode to "PDO::FETCH_ASSOC". $columnA = 1; Selecting Data with the PDO and AES Decryption: Decrypting the encrypted data in mySQL can be done simply by using the decrypt function. Is that easy or what? $columnA = 1; |