我需要在我的 postgres 数据库中存储一个加密的数字。我想将 mcrypt 与 3DES 功能一起使用,加密和解密工作正常,但我无法将其存储在数据库中。我的数据库字段是char(50)
.
$key = "this is a secret key";
$input = "123456789";
$test = mcrypt_ecb(MCRYPT_3DES, $key, $input, MCRYPT_ENCRYPT);
$db = pg_connect("host=localhost dbname=testdb user=haxo");
$sql = "insert into test (pin) values('".$test."')";
$result = pg_query($sql);
if (!$result) {
$errormessage = pg_last_error();
echo "Error with query: " . $errormessage;
exit();
}
pg_close();
我得到的错误是:ERROR: unterminated quoted string at or near "'Ÿlä"