encryption - 使用外部 key 解密加密的 gpg 文件

标签 encryption gnupg

我使用 gpg 加密了一个文件,现在我想解密该文件。

有什么办法可以解密文件而不需要导入 secret 文件吗?

我们将 key 保存在名为 key.sec 的文件中;我们能否将 secret 文件作为参数传递给 gpg(当我们从 bash 命令行运行 decrypt 命令时)以在解密时使用加密文件?或者我们必须导入 key 然后解密加密文件?

最佳答案

您必须将 key 添加到 key 环中。来自 gpg(1) 文档:

   --no-default-keyring
          Do not add the default keyrings to the list of
          keyrings. Note that GnuPG will not operate without any
          keyrings, so if you use this option and do not provide
          alternate keyrings via --keyring or --secret-keyring,
          then GnuPG will still use the default public or secret
          keyrings.

您可以--import --no-default-keyring --secret-keyringtemporary导入 key ,解密时使用--secret-keyringtemporary内容,然后在完成后删除 ~/.gnupg/temporary.gpg 文件。但这只是一种解决方法。

关于encryption - 使用外部 key 解密加密的 gpg 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9073288/

相关文章:

permissions - GPG 权限被拒绝

php - 无法使用 GnuPG 在 PHP 中加密

gnupg - 如何在 GnuPG 中编辑用户 ID 注释或设置新的默认用户 ID?

.Net 中的 PHP crypt() 函数?

c++ - 使用 PGP 公钥在 C++ 中使用 Windows CryptoApi 进行加密

windows - 每次我提交时都阻止 gpg 询问 key

linux - 将 Linux 用户的当前密码与在 Perl 中输入的密码进行比较

security - 为哈希隐藏盐的必要性

azure - Azure 中的 SQL 始终加密

java - 使用 RSA Bouncy CaSTLe 加密/解密无法正常工作