如何处理 ENCRYPE/DECRYPT 中的反斜杠(\)
我正在使用更新查询。 即:-
UPDATE tbl_ecpuser
SET ecpuser_fullname = 'Operator',
ecpuser_password = encrypt(E'Op1111/1\1/1\1' , 'ENCRYPE_KEY', 'ENCRYPE_ALGORITHM'),
where ecpuser_key = '0949600348'
查询正在成功执行。
但是当我尝试检索列 ecpuuser_password 的值时,它 返回一些额外的字符(即-00)
检索密码的查询是:-
SELECT
decrypt(ecpuser_password,'ENCRYPE_KEY','ENCRYPE_ALGORITHM') AS PASSWORD
FROM tbl_ecpuser
WHERE
ecpuser_key = '0949600348'
此查询返回,
"Op1111/1\001/1\001"
但它应该返回“Op1111/1\1/1\1”,我需要这个。
那么任何人都可以帮助我解决这个问题吗?
谢谢。
I m using a update Query.
i.e:-
UPDATE tbl_ecpuser
SET ecpuser_fullname = 'Operator',
ecpuser_password = encrypt(E'Op1111/1\1/1\1' , 'ENCRYPE_KEY', 'ENCRYPE_ALGORITHM'),
where ecpuser_key = '0949600348'
Query is Executing Successfully.
But when I m trying to retrive the value for the Column ecpuser_password, it
returns with some extra character (i.e-00)
The Query for the Retrive the Password is:-
SELECT
decrypt(ecpuser_password,'ENCRYPE_KEY','ENCRYPE_ALGORITHM') AS PASSWORD
FROM tbl_ecpuser
WHERE
ecpuser_key = '0949600348'
This query returens
"Op1111/1\001/1\001"
but it should return "Op1111/1\1/1\1
" and I need this.
So can any body help me about this.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PostgreSQL 不符合 SQL 标准的一个地方是字符串文字中反斜杠的处理。
从 8.2 开始,配置属性 standard_conforming_strings< /a> 可用于将 PostgreSQL 配置为符合此处的标准。
如果将其设置为“on”,
'\1'
将被正确视为具有两个字符(一个反斜杠和字符1
)的字符串。但是如果打开,前缀 E 会再次启用转义序列。
因此(如果我正确理解您的问题)您应该设置
standard_conforming_strings = on
并指定不带前导E
的字符串文字。One place where PostgreSQL was not conforming to the SQL standard was the treatment of a backslash in string literals.
Since 8.2 a configuration property standard_conforming_strings is available that configures PostgreSQL to comply with the standard here.
If you set that to "on"
'\1'
is treated correctly as a string with two characters (one backslash and the character1
).However if that is turned on, the prefix E enables escape sequences again.
So (if I understand your problem correctly) you should set
standard_conforming_strings = on
and specify the string literal without the leadingE
.似乎
E'\1'
被视为 chr(1) 并相应地返回。您可能需要:
E'\\1'
。Seems like
E'\1'
is treated as chr(1) and returned accordingly.You probably want:
E'\\1'
.