目录
  • 前言
  • CertUtil计算文件hash
    • 计算MD2
    • 计算MD4
    • 计算MD5
    • 计算SHA1
    • 计算SHA256
    • 计算SHA384
    • 计算SHA512
  • 文件base64编码
  • 文件base64解码
  • 文件hex编码
  • 文件hex解码
  • 结语

前言

    CertUtil.exe是一个命令行程序,作为证书服务的一部分安装。可以使用CertUtil.exe转储和显示证书颁发机构(CA)配置信息、配置证书服务、备份和恢复CA组件,以及验证证书、密钥对和证书链。如果certutil在没有附加参数的证书颁发机构上运行,它将显示当前的证书颁发机构配置。如果certutil在非认证中心上运行,则该命令默认运行certutil [-dump]命令。
    但是我只用了计算文件hash,以及编码解码文件功能,对我来说在Windows上不用安装额外软件就能实现这些功能很方便。详细说明可以参考【官方文档】

CertUtil计算文件hash

    在Windows的cmd下执行CertUtil -hashfile -?会出现帮助文档,根据Hash algorithms: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512可以得到常用计算文件hash方法,md5和sha1比较常用。

Usage:CertUtil [Options] -hashfile InFile [HashAlgorithm]Generate and display cryptographic hash over a fileOptions:-Unicode          -- Write redirected output in Unicode-gmt              -- Display times as GMT-seconds          -- Display times with seconds and milliseconds-v                -- Verbose operation-privatekey       -- Display password and private key data-pin PIN                  -- Smart Card PIN-sid WELL_KNOWN_SID_TYPE  -- Numeric SID22 -- Local System23 -- Local Service24 -- Network ServiceHash algorithms: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512CertUtil -?              -- Display a verb list (command list)
CertUtil -hashfile -?    -- Display help text for the "hashfile" verb
CertUtil -v -?           -- Display all help text for all verbs

计算MD2

CertUtil -hashfile test.txt MD2
MD2 hash of test.txt:
5892bec299b1bae578d5aff607f6eb61
CertUtil: -hashfile command completed successfully.

计算MD4

CertUtil -hashfile test.txt MD4
MD4 hash of test.txt:
a9c5d7b55b8173b39870bcdf919c71b7
CertUtil: -hashfile command completed successfully.

计算MD5

    计算md5是比较常用的文件hash方式。

CertUtil -hashfile test.txt MD5
MD5 hash of test.txt:
02877f0b701bec19ed79911ccc7b20e3
CertUtil: -hashfile command completed successfully.

计算SHA1

CertUtil -hashfile test.txt SHA1
SHA1 hash of test.txt:
ae36676c8c6a617ed5d3a84b88c70cd5d9c362a5
CertUtil: -hashfile command completed successfully.

计算SHA256

CertUtil -hashfile test.txt SHA256
SHA256 hash of test.txt:
8df1da6d5c8b7a89ed3da070b652946d9db143fd22e98afdccf5d3d1ac3b29e9
CertUtil: -hashfile command completed successfully.

计算SHA384

CertUtil -hashfile test.txt SHA384
SHA384 hash of test.txt:
bc3cf094587ee7473fd460fac1f37db2d3fd7085cfe8d024cfb004d03824d555f46939bd8920a4db32d9e178da064560
CertUtil: -hashfile command completed successfully.

计算SHA512

CertUtil -hashfile test.txt SHA512
SHA512 hash of test.txt:
3b338d0a80a81f95cb8a654c2bcd9ec6385ee9da785708f8e5bb5eba37934d4c2b745faa823f3598fb56b32a32a833defdce3c195f7e4e3a1fa3b3b69f166969
CertUtil: -hashfile command completed successfully.

文件base64编码

    在Windows的cmd执行CertUtil -encode -?可以查看编码文件为base64格式文件。

Usage:CertUtil [Options] -encode InFile OutFileEncode file to Base64Options:-f                -- Force overwrite-Unicode          -- Write redirected output in Unicode-UnicodeText      -- Write output file in Unicode-gmt              -- Display times as GMT-seconds          -- Display times with seconds and milliseconds-v                -- Verbose operation-privatekey       -- Display password and private key data-pin PIN                  -- Smart Card PIN-sid WELL_KNOWN_SID_TYPE  -- Numeric SID22 -- Local System23 -- Local Service24 -- Network ServiceCertUtil -?              -- Display a verb list (command list)
CertUtil -encode -?      -- Display help text for the "encode" verb
CertUtil -v -?           -- Display all help text for all verbs

    下面是对一个文件进行base64编码。结果文件首行和末行会有特殊标记。

CertUtil -encode test.txt test.txt.out
Input Length = 8
Output Length = 70
CertUtil: -encode command completed successfully.cat test.txt
testcat test.txt.out
-----BEGIN CERTIFICATE-----
dGVzdCAgDQo=
-----END CERTIFICATE-----

文件base64解码

    在Windows的cmd执行CertUtil -decode -?可以查看解码base64格式文件。

Usage:CertUtil [Options] -decode InFile OutFileDecode Base64-encoded fileOptions:-f                -- Force overwrite-Unicode          -- Write redirected output in Unicode-gmt              -- Display times as GMT-seconds          -- Display times with seconds and milliseconds-v                -- Verbose operation-privatekey       -- Display password and private key data-pin PIN                  -- Smart Card PIN-sid WELL_KNOWN_SID_TYPE  -- Numeric SID22 -- Local System23 -- Local Service24 -- Network ServiceCertUtil -?              -- Display a verb list (command list)
CertUtil -decode -?      -- Display help text for the "decode" verb
CertUtil -v -?           -- Display all help text for all verbs

    下面是对一个base64文件进行解码。

CertUtil -decode test.txt.out test.txt.de
Input Length = 70
Output Length = 8
CertUtil: -decode command completed successfully.cat test.txt.out
-----BEGIN CERTIFICATE-----
dGVzdCAgDQo=
-----END CERTIFICATE-----cat test.txt.de
test

文件hex编码

    在Windows的cmd执行CertUtil -encodehex -?可以查看编码文件为hex格式文件。

Usage:CertUtil [Options] -encodehex InFile OutFile [type]Encode file in hexadecimalOptions:-f                -- Force overwrite-Unicode          -- Write redirected output in Unicode-UnicodeText      -- Write output file in Unicode-gmt              -- Display times as GMT-seconds          -- Display times with seconds and milliseconds-v                -- Verbose operation-privatekey       -- Display password and private key data-pin PIN                  -- Smart Card PIN-sid WELL_KNOWN_SID_TYPE  -- Numeric SID22 -- Local System23 -- Local Service24 -- Network ServiceCertUtil -?              -- Display a verb list (command list)
CertUtil -encodehex -?   -- Display help text for the "encodehex" verb
CertUtil -v -?           -- Display all help text for all verbs

    下面是对一个文件进行hex编码。结果类似Linux下的xxd格式,展示了文件hex的值。

CertUtil -encodehex test.txt test.hex
Input Length = 23
Output Length = 139
CertUtil: -encodehex command completed successfully.cat test.txt
test1
test2
test3cat test.hex
0000    74 65 73 74 31 0d 0a 74  65 73 74 32 0d 0a 74 65   test1..test2..te
0010    73 74 33 0d 0a 0d 0a                               st3....

文件hex解码

    在Windows的cmd执行CertUtil -decodehex -?可以查看解码hex格式文件。

Usage:CertUtil [Options] -decodehex InFile OutFile [type]Decode hexadecimal-encoded filetype -- numeric CRYPT_STRING_* encoding typeOptions:-f                -- Force overwrite-Unicode          -- Write redirected output in Unicode-gmt              -- Display times as GMT-seconds          -- Display times with seconds and milliseconds-v                -- Verbose operation-privatekey       -- Display password and private key data-pin PIN                  -- Smart Card PIN-sid WELL_KNOWN_SID_TYPE  -- Numeric SID22 -- Local System23 -- Local Service24 -- Network ServiceCertUtil -?              -- Display a verb list (command list)
CertUtil -decodehex -?   -- Display help text for the "decodehex" verb
CertUtil -v -?           -- Display all help text for all verbs

    下面是对一个hex文件进行解码。

CertUtil -decodehex test.hex test.hex.out
Input Length = 139
Output Length = 23
CertUtil: -decodehex command completed successfully.cat test.hex
0000    74 65 73 74 31 0d 0a 74  65 73 74 32 0d 0a 74 65   test1..test2..te
0010    73 74 33 0d 0a 0d 0a                               st3....cat test.hex.out
test1
test2
test3

结语

    熟练使用这个命令,可以方便的在Windows电脑上校验文件,以及编码解码文件。特别是编码为hex格式文件,可以分析文件的二进制数据。我以前遇到过文件包含不可见字符导致代码编译报错,却找不到哪里错误,这时候分析文件的二进制数据一目了然了。

Windows下CertUtil校验和编码文件相关推荐

  1. Windows下右键新建.md文件教程(转)

    Windows下右键新建.md文件教程 转载自Keavnn'Blog,并有些许修正 原本创建.md文件需要首先打开markdown文本编辑器,如Typora,或者新建.txt文件然后修改后缀名,本文介 ...

  2. Htaccess文件是什么以及Windows下自由创建.htaccess文件的N种方法

    .htaccess是什么 概述来说,htaccess文件是Apache服务器中的一个配置文件,它负责相关目录下的网页配置. 通过htaccess文件,可以帮我们实现:网页301重定向.自定义404错误 ...

  3. Windows下批量删除旧文件、清除缓存文件、解救C盘、拒绝C盘爆炸

    Windows下批量删除旧文件.清除缓存文件.解救C盘.拒绝C盘爆炸 目录 Windows下批量删除旧文件.清除缓存文件.解救C盘.拒绝C盘爆炸 #删除旧文件1 #删除旧文件2 #删除旧文件1 rem ...

  4. 使用Python批量删除windows下特定目录的N天前的旧文件实战:Windows下批量删除旧文件、清除缓存文件、解救C盘、拒绝C盘爆炸

    使用Python批量删除windows下特定目录的N天前的旧文件实战:Windows下批量删除旧文件.清除缓存文件.解救C盘.拒绝C盘爆炸 目录

  5. linux下find查找带有指定权限的文件(windows下编译的源代码文件)

    find -type f -perm -o=x 查找用户在windows下编译的源代码文件 转载于:https://blog.51cto.com/axlrose/1357610

  6. windows下快速创建大文件

    windows下快速创建大文件 F:/>fsutil file createnew wu 20480000000 已创建文件 F:/wu 也可以使用API SetEndOfFile

  7. windows下安装phpcms html/ 文件夹不可写的一种错误以及解决方法

    windows下安装phpcms html/ 文件夹不可写的一种错误以及解决方法 参考文章: (1)windows下安装phpcms html/ 文件夹不可写的一种错误以及解决方法 (2)https: ...

  8. Windows下快速获取一个文件夹下所有文件的名称列表

    Windows下快速获取一个文件夹下所有文件的名称列表 进入windows终端:win+R 输入cmd,回车 使用cd命令进入到目标文件夹.例如: 先进入D盘,输入d: 回车, 然后 cd openc ...

  9. 将windows下编辑好的文件(GBK)转换成Linux下的格式(UTF8)

    背景:一般我们在windows上编辑好的文件默认编码是GBK,而且换行符是^M,为了将这些文件用在linux上,我们一般会将它们转换成Linux下的文件格式,即去掉^M,且将文件格式转换成UTF8. ...

最新文章

  1. 第七届“数学、计算机与生命科学交叉研究” 青年学者论坛
  2. 2020年2月Github上最热门的开源项目
  3. 订单BOM与销售BOM的区别
  4. centos7重启网卡命令_重启 CentOS 7 系统后的 IP 地址问题
  5. 106页《Python进阶》中文版介绍分享
  6. leetcode-Single Number II-137
  7. Spring Bean的序列化方案
  8. pdf数据填充,JaspersoftStudio,JasperReport
  9. cadlisp框选打印_caD批量打印LISP程序,因为工作需要。只要LISP的。
  10. c语言算除法会把小数转成整数,在C语言中除法运算为什么没有小数部分?
  11. android 公式编辑器,公式编辑器
  12. OAuth2资源服务器
  13. Wampserver图标是橙色的【问题与解决方案】
  14. unity3d 地面印花_Unity3D 中的贴花效果 – 苍白的茧
  15. 使用WinRE向Windows10中添加新的本地管理员账户
  16. 【Linux】Linux input子系统之Input event codes
  17. GRUB2配置文件grub.cfg详解
  18. iPhone4s刷机教程
  19. 中国移动支付报告:领跑全球 前景广阔
  20. paydex什么币-区块链钱包

热门文章

  1. Bison^Flex=语法分析生成中
  2. C语言(较深入原理):%s通过字符串首元素地址输出,用指针数组来作示例
  3. 计算机图形学顶级杂志、会议、期刊
  4. vue:单文件的使用
  5. Docker篇之启动容器
  6. 奇安信发布冬奥网络安全“零事故”态势感知研判系统
  7. 容器编排之战(三)连载
  8. highlight.js(代码高亮插件)
  9. win10下AirSim搭建
  10. 高级java开发必问面试题