我试图用powershell解密自动pgp消息但是它丢弃了一条错误消息:“gpg:decrypt_message failed:No such file or directory”
标志和加密部分是使用命令行命令完成的:
$path = "\\networkdrive\folder1\message"
$step2files = Get-ChildItem -Recurse -Path $path | Where-Object{$_.Extension -eq ".asc"}
$z=1
foreach ($files in $step2files) {
$outputname = "$files.pgp"
$input = $files
$z
$options = " --output $outputname –-encrypt --recipient XYKey $files"
$options
gpg --output $outputname --encrypt --recipient XYKey $input
$z++
}
我需要以类似的方式解密响应,即使powershell找到所有相应的文件,也会显示上述错误消息。
代码部分是:
$extracted = "\\networkdrive\folder1\extracted"
$step5files = Get-ChildItem -Recurse -Path $extracted | Where-Object{$_.Extension -eq ".pgp"}
$z=1
foreach ($files in $step5files) {
$outputname = "$files.xml"
$input = $files
$z
$options = " -u KeyID --batch --yes --passphrase password --output $outputname --decrypt $files"
$options
gpg -u KeyID --batch --yes --passphrase password --output $outputname --decrypt $input
$z++
}
任何想法?
我正在使用最新的GnuPG,这在我的结尾很好用:
$cipher = "My secret message" | gpg -ear 'MyRecipient'
Write-Host $chipher
$message = $cipher | gpg --batch --yes --passphrase 'MyPassphrase'
Write-Host $message