- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个批处理文件来解密 .gpg
的文件夹用相同的公钥加密的文件。这是我到目前为止:
@ECHO off
SET outbound=C:\encrypted files
SET olddir=%CD%
SET password=correcthorsebatterystaple
CD /d %outbound%
DIR *.gpg /B > tmp.txt
FOR /F "tokens=*" %%F IN (tmp.txt) DO (
ECHO %%F > tmplen.txt
FOR %%L IN (tmplen.txt) DO (SET namelen=%%~zL)
DEL tmplen.txt
gpg --output %%F:~0, namelen-4 --batch --yes --passphrase %password% --decrypt %%F)
DEL tmp.txt
CD /d %olddir%
usage: gpg [options] [filename]
最佳答案
以下应该工作:
@ECHO off
SET password=correcthorsebatterystaple
PUSHD "C:\encrypted files"
FOR /F "tokens=*" %%F IN ('DIR *.gpg /B') DO (
gpg --output %%~nF --batch --yes --passphrase %password% --decrypt %%F)
POPD
PUSHD
和 POPD
用于临时进入另一个目录; DIR
的输出, 因为 FOR
还能够解析命令的输出(IN ()
中的集合被 ''
括起来,因此它被解释为命令,而不是文件规范。); FOR
循环做什么,至少根据我的解释),您只需要提供修饰符 ~n
, 在我们的情况下 %%~nF
;您的方法不起作用,因为:namelen-4
所尝试的那样进行在线数学运算(您需要将临时变量与 SET /A
一起用于算术运算,然后 delayed expansion 必须处于事件状态); :~0,8
不适用于 FOR
变量(您需要一个临时变量来执行此操作,然后 delayed expansion 必须再次处于事件状态); gpg
命令行:
gpg --output "%%~nF" --batch --yes --passphrase %password% --decrypt "%%~F"
~
修饰符删除潜在的双引号,所以
"%%~nF"
和
"%%~F"
始终用双引号将文件名括起来。请注意
"%%F"
可能会无意中导致双双引号......
关于batch-file - 批处理脚本GPG解密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31707172/
(kubuntu,但在我的方法中试图保持平台独立。) 概念解释或必要步骤都值得赞赏。 我正在阅读文档,并试图获取 gpg-agent工作一次,但我感到气馁,因为每次尝试都需要重新启动,而且我并不真正理
记录遇到的问题; 在aliyun上安装MySQL时由于上次错误卸载mysql 导致校验文件出问题; 处理方式有几种 1到mysql官网下载校验文件 2跳过校验,记录第二种 编
我想为一个 atm 创建一个自动 GnuPG key 生成脚本,尽管他们运行 ubuntu,但不习惯使用 CLI。此外,其他人管理他们的计算机,使其保持最新状态并处于良好的运行状态,因此他们也没有 r
我刚刚不小心丢失了旧的 gpg key 。我想知道我是否可以删除每个提交的 gpg 标志或使用我的新 gpg key 重新签名? 最佳答案 我知道这是一个老问题,但我遇到了类似的情况,我不得不签署(实
作为 perl 脚本的一部分,我根据从电子邮件中获得的周期数从网站下载一些文件。我使用正则表达式找到合适的周期数,将其附加到 url 并从所述 url 获取加密文件。然后我将加密文件打印到临时文件,并
查看Subj:如何在不使用本地存储(在〜/.gpg下)的情况下从gpg中的私有(private)获取公钥? 此解决方案不满足要求: $ gpg --import priv.key $ gpg --ex
我有 1 个 github 用户和另一个 gitlab 用户,我为每个用户创建了 1 个 gpg key ,因为我的电子邮件地址不同。 问题是我必须执行 git config --global use
我在运行这段代码时遇到了这个错误。 gpg --fingerprint gpg: WARNING: unsafe ownership on configuration file `/home/dyla
我遵循本教程:https://help.github.com/articles/signing-commits-using-gpg/ 我尝试像这样提交时签名: https://github.com/s
我从 brew 安装了 GPG。 brew install gpg 它是 gnupg2-2.0.30_2。 当我提交时,我确实收到一条错误消息: You need a passphrase to un
在我添加 docker GPG key 时设置 docker 存储库 cmd- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | su
我全新安装了 Linux Mint 14。安装了 Thunderbird 和 Enigmail。 生成我的 key ,得到一个 friend 的公钥,导入它。 给我的 friend 发了一封加密的电子
我是 Unix 和 ksh 脚本编写的新手。我写了一个解密 gpg 消息的脚本。我收到此错误,我不知道如何解决。我希望有人可以查看我的脚本并帮助我弄清楚发生了什么。感谢您提供的任何帮助。 这是错误:
我正在尝试在我的 ubuntu 机器上安装 chirpstack。尝试设置 key 时出现以下错误。 jonny@jonny-ubuntu:~$ sudo gpg --keyserver keyser
我正在为 Web 开发设置新机器 (macOS Sierra),我已经完成 brew install gpg 安装了 gpg2 和 gpg-agent。我已经从旧 Mac 上的 ~.gnupg 复制了
我正在使用以下命令 gpg --keyserver hkp://pool.sks-keyservers.net --send-keys 按照本文的指导https://getstream.io/blo
尝试将我们的基本镜像迁移到稳定的 Ubuntu 18.04,当我们尝试添加我们的 gpg key 时,出现此错误: root@77ff14f29cab:/# apt-key add apt-key.g
我运行的是GitHub工作流,过去我曾多次使用该工作流将代码发布到Nexus.它现在正在失败。我已经有一段时间没有使用它了,所以我的原始密钥可能已经过期了……自从我创建它以来,已经超过3年了,我不记得
我收到一个错误: gpg: no default secret key: No secret key gpg: [stdin]: clearsign failed: No secret key GPG
如何在 Scala 中解密 OpenPGP 加密文件?我有公钥和私钥,并且 gpg --output file.txt --decrypt file.txt.gpg 有效。 最佳答案 从 PR 到 h
我是一名优秀的程序员,十分优秀!