批量解码base64 [英] Decoding base64 in batch

查看:649
本文介绍了批量解码base64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用批处理方式创建安装程序.当然,安装程序需要包含将要安装的文件,因此我正在考虑在base64中对文件进行编码,然后将其解码并将其写入目标位置.

I am trying to make an installer using batch. Of course, an installer needs to consist of files that will be installed, so I'm thinking of encoding the files in base64, and simply decode them and write them to their destination.

当然,如果Windows具有Linux盒子中包含的base64工具之类的东西,我的工作将会非常轻松.但是,由于根本不存在,有没有办法使用批处理文件完全解码base64内容?而我将如何实现呢?

Of course, my work would be very easy if Windows had something like the base64 tool that Linux boxes contain. However, since it's simply not there, is there any way to decode base64 content completely using batch files? And how would I accomplish this?

感谢您的帮助.

(这只是一个实验,所以我不必担心效率低下之类的问题.)

(It's just an experiment, so I'm not worried about inefficiency and the like.)

推荐答案

实际上Windows确实具有可对base64进行编码和解码的实用程序-CERTUTIL

Actually Windows does have a utility that encodes and decodes base64 - CERTUTIL

我不确定哪个版本的Windows引入了此命令.

I'm not sure what version of Windows introduced this command.

要编码文件:

certutil -encode inputFileName encodedOutputFileName

要解码文件:

certutil -decode encodedInputFileName decodedOutputFileName

CERTUTIL有许多可用的动词和选项.

There are a number of available verbs and options available to CERTUTIL.

要获取几乎所有可用动词的列表:

To get a list of nearly all available verbs:

certutil -?

要获取有关特定动词(例如-encode)的帮助,

To get help on a particular verb (-encode for example):

certutil -encode -?

要获取几乎所有动词的完整帮助:

To get complete help for nearly all verbs:

certutil -v -?

神秘地,-encodehex动词未与certutil -?certutil -v -?一起列出.但是使用certutil -encodehex -?进行了描述.这是另一个方便的功能:-)

Mysteriously, the -encodehex verb is not listed with certutil -? or certutil -v -?. But it is described using certutil -encodehex -?. It is another handy function :-)

关于David Morales的评论,有一个-encodehex动词>记录不清的类型选项,它允许创建没有页眉或页脚行的base64字符串.

Regarding David Morales' comment, there is a poorly documented type option to the -encodehex verb that allows creation of base64 strings without header or footer lines.

certutil [Options] -encodehex inFile outFile [type]

类型1会产生没有页眉或页脚行的base64.

A type of 1 will yield base64 without the header or footer lines.

请参见 https://www.dostips.com/forum/viewtopic.php?f=3&t=8521#p56536 简要列出可用的类型格式.要更深入地了解可用格式,请参见 https://www.dostips.com/forum/viewtopic.php?f=3&t=8521#p57918 .

See https://www.dostips.com/forum/viewtopic.php?f=3&t=8521#p56536 for a brief listing of the available type formats. And for a more in depth look at the available formats, see https://www.dostips.com/forum/viewtopic.php?f=3&t=8521#p57918.

未经调查,但-decodehex动词还具有可选的尾随类型参数.

Not investigated, but the -decodehex verb also has an optional trailing type argument.

这篇关于批量解码base64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆