1
我想加密和解密字符串。 现在我已经做到了这一点:gpg加密和解密
[email protected]:~$ echo "hallo" | gpg --symmetric --pgp8 --cipher-algo AES256 > /tmp/1
Enter passphrase:
Repeat passphrase:
[email protected]:~$
[email protected]:~$ cat /tmp/1 | gpg --decrypt
gpg: AES256 encrypted data
Enter passphrase:
gpg: encrypted with 1 passphrase
hallo
[email protected]:~$
它的工作原理就像我希望它的工作。现在,我已经使用密码出文件的尝试过,但没有奏效:
[email protected]:~$ echo "hallo" | gpg --symmetric --pgp8 --cipher-algo AES256 --passphrase-fd 0 </home/mis/testgpg> /tmp/1
Reading passphrase from file descriptor 0
[email protected]:~$
[email protected]:~$ cat /tmp/1 | gpg --decrypt
gpg: AES256 encrypted data
gpg: encrypted with 1 passphrase
这是非常有趣的,他询问密码。如果我写错了,我会收到一条错误消息,但是如果我写了正确的密码短语,我就不会收到我的密码字符串。 我的目标是要达到这样的:
[email protected]:~$ echo "hallo" | gpg --symmetric --pgp8 --cipher-algo AES256 --passphrase-fd 0 </home/mis/testgpg> /tmp/1
Reading passphrase from file descriptor 0
[email protected]:~$
[email protected]:~$ cat /tmp/1 | gpg --decrypt --passphrase-fd 0 < /home/mis/testgpg
Reading passphrase from file descriptor 0
gpg: decrypt_message failed: eof
[email protected]:~$
但是,这也不行。有谁知道,我做错了什么?