用 certutil 做 Base64 编码和解码
Windows 自带的 base64 工具:certutil -encode / -decode,无需安装任何东西。
运行 certutil -encode <输入> <输出> 将文件编码为 base64,用 certutil -decode <输入> <输出> 解回。
01命令
命令
$ certutil -encode in.txt out.b64 ; certutil -decode out.b64 restored.txt02作用说明
certutil 的 -encode/-decode 针对整个文件而非字符串,解码器也接受其他工具产生的 base64 输出。加 -f 可覆盖已存在的输出文件。十六进制转储对应 -encodehex/-decodehex;在 PowerShell 中如只是处理单个字符串,也可直接用 [Convert]::ToBase64String,不必走文件往返。
03风险
!注意: certutil -decode 会把原始字节写到输出路径——解码本身不会执行任何代码,但不要盲目解码并打开来源不明的附件。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- certutil | Microsoft Learn依据: Microsoft documents certutil -encode and -decode converting files to and from base64, plus -encodehex/-decodehex for hexadecimal.
- CERTUTIL - Windows CMD依据: SS64 lists -encode/-decode base64 conversion and -decodehex, noting the -f flag to force overwrite of output files.
最后验证: 2026-09-17 · 分类: 开发者