Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Npgsql将不处理pgp_sym_decrypt查询-从命令行运行_Postgresql_Encryption_Npgsql - Fatal编程技术网

Postgresql Npgsql将不处理pgp_sym_decrypt查询-从命令行运行

Postgresql Npgsql将不处理pgp_sym_decrypt查询-从命令行运行,postgresql,encryption,npgsql,Postgresql,Encryption,Npgsql,我在一个表中有一个定义为bytea的列,它使用十六进制编码的密码进行了加密 我可以从putty中读出如下数据: SELECT pgp_sym_decrypt(_encypted_text, E'\\x465af9b6f0ea0207188236e8698c76772f4fedcbc39fabf29c2c4d98b23d4e72') FROM msg; pgp_sym_decrypt ------------------ This is the text (1 row) 但是,当我使用Npg

我在一个表中有一个定义为bytea的列,它使用十六进制编码的密码进行了加密

我可以从putty中读出如下数据:

SELECT pgp_sym_decrypt(_encypted_text, E'\\x465af9b6f0ea0207188236e8698c76772f4fedcbc39fabf29c2c4d98b23d4e72') FROM msg;
 pgp_sym_decrypt
------------------
 This is the text
(1 row)
但是,当我使用Npgsql运行同一查询时,它会引发一个异常:

Npgsql.PostgresException: 39000: Wrong key or corrupt data
我使用的代码是

        // create new connection
        con = new NpgsqlConnection(m_ConnectString);

        // setup certificate handler
        con.UserCertificateValidationCallback = theUserCertificateValidationCallback;

        // setup query string
        strQuery = "SELECT pgp_sym_decrypt(_encypted_text, E'\\x465af9b6f0ea0207188236e8698c76772f4fedcbc39fabf29c2c4d98b23d4e72') FROM msg ";

        // create a new comnmand using the query and connection
        cmd = new NpgsqlCommand(strQuery, con);

        // open the connection
        con.Open();

        // execute the query
        reader = cmd.ExecuteReader();
最后一行触发异常处理程序

你知道为什么这两个接口的行为不同吗?
如何通过Npgsql解密?

我发现查询可能需要通过API进行第二级解析。因此,需要第二套逃生卡

开始时所需的密码

E'\\\\x
而不是

E'\\x
当通过API使用时