gpt4 book ai didi

php - 从 mysql pdo php 解密的值

转载 作者:行者123 更新时间:2023-11-29 11:28:47 25 4
gpt4 key购买 nike

$stmt2 = $dbh-> prepare("Select * from encryptme where ".decrypt('encryptedcolumn', $key)." = ?");
$stmt2 -> bindValue(1, $dec, PDO::PARAM_STR);
$stmt2 -> execute();

我有 encrypt()decrypt() 我在使用 encrypt() 后保存数据,现在我想选择数据,但是我无法,因为数据已加密。我尝试的是我在列名称中使用了该函数,但它不起作用,我收到错误消息

Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '

如何解密查询语句中的列?

最佳答案

查询时不能使用 php 函数解密数据库中的值。 (不过,如果数据库函数支持加密方法,您可以使用它)

您可以改为将加密参数发送到数据库,以将其与加密存储值进行比较。

获取数据后,您可以解密该值以执行您需要的任何操作。

新信息后编辑:

如果您无法可靠地加密 php 中的值,则必须从数据库中获取所有数据,然后解密,以便可以比较这些值。

关于php - 从 mysql pdo php 解密的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37762175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com