Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.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和hmac-sha2-256加密文件_Batch File_Encryption_Hmac - Fatal编程技术网

Batch file 使用gpg和hmac-sha2-256加密文件

Batch file 使用gpg和hmac-sha2-256加密文件,batch-file,encryption,hmac,Batch File,Encryption,Hmac,我编写了一个脚本,使用gpg对文件进行加密,该脚本使用.bat脚本,该脚本接收从powershell脚本传递的文件名。这是我的.bat文件(重要的部分): 其中SetEncryptionSettings.txt如下所示: Key-Type: default Subkey-Type: default Name-Real: myuser Name-Comment: nocomment Name-Email: me@gmail.com Expire-Date: 0 这是有效的。我可以自己解密这个文件

我编写了一个脚本,使用gpg对文件进行加密,该脚本使用.bat脚本,该脚本接收从powershell脚本传递的文件名。这是我的.bat文件(重要的部分):

其中SetEncryptionSettings.txt如下所示:

Key-Type: default
Subkey-Type: default
Name-Real: myuser
Name-Comment: nocomment
Name-Email: me@gmail.com
Expire-Date: 0
这是有效的。我可以自己解密这个文件。然而,我把我的文件发送给了另一个似乎使用不同解密算法的人……他说我应该使用hmac-sha2-256

我了解.bat文件中的加密选项,以提供以下四个选项:

(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
可以在这里看到,例如:


所以我认为我的代码使用的是RSA,因为这是默认的…而且因为这里没有hmac-sha2-256的选项,所以我现在必须改变一切。我是否可以使用与现在类似的设置来完成这项工作,而无需下载任何其他程序?

我不了解批处理文件的需要
gpg.exe
是一个标准的可执行文件,没有明显的理由不直接在PowerShell脚本中运行它。您的意思是从PowerShell脚本中调用gpg?嗯,也许我可以,我已经花了很多时间按照我的方式修改它,所以我不想完全重写东西……但这能解决hmac-sha2-256的问题吗?我的服务器上只有运行此脚本的powershell 2.0。我从一个外部程序调用该应用程序,该程序调用其他程序时可能会出现问题,但我知道它可以与.bat脚本一起使用。实际上没有什么需要更改的,请在PowerShell中创建变量
$OutputParam
,然后像在批处理文件中一样添加这两个命令。但是,可执行文件的功能,
gpg.exe
不会改变,如果它不起作用,更改接口将无法修复它。因此,进行此更改将允许我使用hmac-sha2-256?hmac-SHA-256(应该拼写为hmac-SHA-256)加密文件,这是一种基于哈希的MAC,一种消息身份验证代码。它不加密。我想你应该回到另一方,要求对方作出澄清或举例说明,因为这不会让你一事无成。您不能仅仅通过相互抛出算法来决定协议。
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)