通过PDO-PreparedStatement将AES加密的字符串插入MySQL失败

时间:2019-02-07 10:51:49

标签: php mysql pdo aes prepared-statement

我试图在我的 MySQL-Datebase using PDO-Prepared语句中插入一个 AES加密的密码字符串。可悲的是,我几乎没有失败,也不知道为什么。

$sqlString = "REPLACE INTO :dbtable (username,textaes) VALUES (:ou,:encrypted)";    
try {
    $stmtUpdate = $rrcenterPDO->prepare($sqlString);
    $stmtUpdate->bindParam(':dbtable', $dbTable, PDO::PARAM_STR);
    $stmtUpdate->bindParam(':ou', $ou, PDO::PARAM_STR);
    $stmtUpdate->bindParam(':encrypted', $encrypted, PDO::PARAM_LOB);

    $ret = $stmtUpdate->execute();
} catch(Exception $e) {
   echo "Replace failed";
}

print_r($stmtUpdate->errorInfo());

从errorInfo打印的错误是     您的 SQL语法中有错误;检查与您的 MariaDB 服务器版本相对应的手册,以获取在''otpTable'(用户名,文本)VALUES(第1行的'unclesam')附近使用的正确语法。

因此,我在mysql服务器上激活了常规日志文件,并在其中找到了以下语句:

REPLACE INTO 'otpTable' (username,textaes) VALUES ('unclesam','˯Ł\nPKﲫ')

很明显,PDO以任何方式“更改”了加密字符串,因此mysql-db无法插入blob。...但是我不知道为什么,如何以及如何更改它,以便它会正常运行。...

有人知道一些提示吗?

感谢您和最诚挚的问候 本杰明

0 个答案:

没有答案