francois=# select quoi,login,pgp_sym_decrypt_bytea(password,'mykey') from passwd where quoi ilike '%tocken%' ;
ERREUR: Wrong key or corrupt data
直到现在,这才突然发生。
所以
psql -c " select pgp_sym_decrypt(password,'somekey') from passwd where quoi ilike '%tocken%' ;"
pgp_sym_decrypt
--------------------------------------
d728isperfectlyworkinge71ef
(1 ligne)
我错过了什么?这对我所有的密码库都是一样的。从 psql 内部调用 pgp_sym_decrypt 失败,但不是外部调用
完整示例:
?francois@?zaphod?:~$ psql
psql (13.2 (Debian 13.2-1), serveur 11.11 (Debian 11.11-0+deb10u1))
Saisissez « help » pour l'aide.
francois=# select pgp_sym_decrypt_bytea(password,'xxxx') from passwd where quoi ilike '%tocken%' ;
ERREUR: Wrong key or corrupt data
francois=# select pgp_sym_decrypt(password,'xxxx') from passwd where quoi ilike '%tocken%' ;
ERREUR: Wrong key or corrupt data
francois=# \q
?francois@?zaphod?:~$ psql -c "select pgp_sym_decrypt(password,'xxxx') from passwd where quoi ilike '%tocken%' ;"
ERREUR: Wrong key or corrupt data
?francois@?zaphod?:~$ psql -c "select pgp_sym_decrypt_bytea(password,'xxxx') from passwd where quoi ilike '%tocken%' ;"
ERREUR: Wrong key or corrupt data
?francois@?zaphod?:~$ ?francois@?zaphod?:~$ psql -c "select quoi,login,pgp_sym_decrypt(password,'xxxxx') from passwd where quoi ilike '%tocken%' ;"
quoi | login | pgp_sym_decrypt
------------------+------------------+--------------------------------------
xxxxxxxxx tocken | xxxxxxxxxxxxxxxx | d728d529-6be2-45f9-a7c2-126fa01e71ef
(1 ligne)
?francois@?zaphod?:~$
似乎是随机的...
好吧,根据您发布的内容,我发现您在两次通话中都使用了不同的键。
所以我把它们贴在了下面,看起来你也调用了完全不同的函数!
哎呀?
但是...您为什么
要解密密码?
如果有人掌握了您的数据库和您的密钥,您所有用户的密码都会被泄露。
密码应存储为 [单向] 散列值,并且仅应针对这些散列值进行比较。