【发布时间】:2011-09-02 13:43:58
【问题描述】:
我正在尝试加密和解密字符串。 现在我已经这样做了:
mis@fasan:~$ echo "hallo" | gpg --symmetric --pgp8 --cipher-algo AES256 > /tmp/1
Enter passphrase:
Repeat passphrase:
mis@fasan:~$
mis@fasan:~$ cat /tmp/1 | gpg --decrypt
gpg: AES256 encrypted data
Enter passphrase:
gpg: encrypted with 1 passphrase
hallo
mis@fasan:~$
它就像我想要的那样工作。现在我用文件中的密码尝试了它,但它没有用:
mis@fasan:~$ echo "hallo" | gpg --symmetric --pgp8 --cipher-algo AES256 --passphrase-fd 0 < /home/mis/testgpg > /tmp/1
Reading passphrase from file descriptor 0
mis@fasan:~$
mis@fasan:~$ cat /tmp/1 | gpg --decrypt
gpg: AES256 encrypted data
gpg: encrypted with 1 passphrase
很有趣,他要求输入密码。如果我写错了,我会收到一条错误消息,但如果我写了正确的密码,我就不会得到我的密码字符串。 我的目标是达到这个目标:
mis@fasan:~$ echo "hallo" | gpg --symmetric --pgp8 --cipher-algo AES256 --passphrase-fd 0 < /home/mis/testgpg > /tmp/1
Reading passphrase from file descriptor 0
mis@fasan:~$
mis@fasan:~$ cat /tmp/1 | gpg --decrypt --passphrase-fd 0 < /home/mis/testgpg
Reading passphrase from file descriptor 0
gpg: decrypt_message failed: eof
mis@fasan:~$
但这也不起作用。有谁知道,我做错了什么?
【问题讨论】:
标签: linux console console-application gnupg