Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 使用批处理文件解密GPG文件_Batch File_Encryption_Gnupg - Fatal编程技术网

Batch file 使用批处理文件解密GPG文件

Batch file 使用批处理文件解密GPG文件,batch-file,encryption,gnupg,Batch File,Encryption,Gnupg,我正在使用一个批处理文件和下面的代码解密一个gpg文件 gpg.exe --output test.csv --batch --passphrase-fd 0 --decrypt WSB330TJ.CSTDJIDF.TXT.asc.14.04.22_00.59.gpg 虽然它确实解密了文件,但我必须手动输入密码短语。 如何改进它,使其能够自动选择密码短语并解密文件,而无需任何手动干预? 我应该在这里添加什么?您告诉GnuPG使用--passphrase fd 0从stdin读取密码短语。从ma

我正在使用一个批处理文件和下面的代码解密一个gpg文件

gpg.exe --output test.csv --batch --passphrase-fd 0 --decrypt WSB330TJ.CSTDJIDF.TXT.asc.14.04.22_00.59.gpg
虽然它确实解密了文件,但我必须手动输入密码短语。 如何改进它,使其能够自动选择密码短语并解密文件,而无需任何手动干预?
我应该在这里添加什么?

您告诉GnuPG使用
--passphrase fd 0
从stdin读取密码短语。从
man gpg
,有不同的选项来读取密码短语:

   --passphrase-fd n
          Read the passphrase from file descriptor n.  Only  the  first  line
          will  be  read  from  file  descriptor  n.  If you use 0 for n, the
          passphrase will be read from STDIN. This can only be used  if  only
          one passphrase is supplied.

   --passphrase-file file
          Read  the  passphrase  from  file file. Only the first line will be
          read from file file. This can only be used if only  one  passphrase
          is  supplied.  Obviously, a passphrase stored in a file is of ques-
          tionable security if other users can read this file. Don't use this
          option if you can avoid it.

   --passphrase string
          Use  string  as  the  passphrase. This can only be used if only one
          passphrase is supplied. Obviously, this  is  of  very  questionable
          security  on  a multi-user system. Don't use this option if you can
          avoid it.
如果使用GnuPG 2,请记住使用
--batch
,否则将忽略密码短语选项

如果将密码短语存储在文件中,请使用
--passphrase file password.txt
,如果要将其作为字符串传递,请使用
--passphrase“f00b4r”
(当然,两次都使用适当的参数值)


@Thierry在评论中指出(特别是在使用Windows时),确保文件结尾使用UNIX换行符(
\n
/LN),而不是Windows换行符+回车符(
\n\r
/LNRF)。

对于我自己,我必须做*
gpg--batch--password“MyPassword”--解密文件C:\PGPFiles\\\*.pgp*
使用
--密码短语
不在
之前执行--解密文件
将始终提示我输入密码。正如Thierry所说,当我使用密码文件时,我必须使用Notepad++转换为unix样式
(编辑->下线->unix/OSX格式)

尝试以下方法:

gpg2 -se --passphrase yourpassword --batch --yes -r user@mydomain.com filename

您试过了吗?没有,会更简单吗?似乎没有处理文件或直接传递密码短语。您是否删除了
--passphrase fd
参数?“不工作”也不是一个有用的问题描述。你是怎么尝试的,发生了什么,什么情况没有发生?gpg.exe--output test.csv--batch--passphrase xyz--decrypt WSB330TJ.CSTDJIDF.TXT.asc.14.04.22_00.59.gpg上面的命令要求输入密码短语,然后解密文件我发现在使用--passphrase file with gpg4win时,密码短语文件必须有unix行分隔符而不是dos/windows\r\n分隔符。