如何解密使用GPG对称加密的文件?

gwg*_*gwg 8 security gpg pgp

我使用 GPG 创建并对称加密了一个文件:

touch test.txt && echo 'test' >> test.txt
gpg --output test.txt --symmetric test.txt
Run Code Online (Sandbox Code Playgroud)

但现在我不知道如何解密它,而且令人惊讶的是,我在网上找不到示例。这是我尝试过的:

touch test.txt && echo 'test' >> test.txt
gpg --output test.txt --symmetric test.txt
Run Code Online (Sandbox Code Playgroud)
$ gpg --decrypt test.txt
gpg: AES encrypted data
gpg: encrypted with 1 passphrase
Run Code Online (Sandbox Code Playgroud)
$ gpg --symmetric --decrypt test.txt
gpg: conflicting commands
Run Code Online (Sandbox Code Playgroud)
$ gpg --passphrase --decrypt test.txt
gpg: no valid OpenPGP data found.
gpg: decrypt_message failed: Unknown system error
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

Ste*_*itt 4

正确的命令是

\n\n
gpg --decrypt test.txt\n
Run Code Online (Sandbox Code Playgroud)\n\n

gpg在读取其输入之前覆盖其输出,因此您的test.txt\xe2\x80\x99s 原始内容丢失了。

\n\n

您需要加密到不同的文件:

\n\n
gpg --output test.gpg --symmetric test.txt\n
Run Code Online (Sandbox Code Playgroud)\n