A lightweight Windows batch script to compute file hashes via PowerShell's
Get-FileHash.
这是一个轻量级的 Windows 批处理脚本,借助 PowerShell 内置的 Get-FileHash 命令,快速计算文件的哈希值。
This is a lightweight Windows batch script that uses PowerShell's Get-FileHash cmdlet to quickly compute file hashes.
支持拖拽多个文件和交互式菜单,也支持命令行直接传入文件路径。
It supports drag‑and‑drop of multiple files, an interactive menu, and command‑line arguments.
-
交互菜单 – 启动后显示算法列表,输入数字选择,或输入
a一次性计算全部 7 种哈希。
Interactive menu – choose an algorithm by number, or enterafor all 7 hashes. -
拖拽支持 – 将文件直接拖到批处理文件图标上。
Drag‑and‑drop – drop files onto the batch file. -
多文件处理 – 依次处理每个拖入的文件,并分别显示结果。
Multi‑file processing – each file is processed and its hash(es) displayed. -
支持算法(Supported algorithms):
- SHA1
- SHA256
- SHA384
- SHA512
- MACTripleDES
- MD5
- RIPEMD160
-
全部计算模式 – 选择
a后,对每个文件依次计算以上所有哈希。
All‑in‑one mode – computes all 7 algorithms for every file.
- Windows 操作系统(已在 Windows 10 / 11 上测试)
Windows OS (tested on Windows 10 / 11) - PowerShell(所有现代 Windows 均预装)
PowerShell (pre‑installed on all modern Windows)
-
下载
hash.bat到任意文件夹。
Downloadhash.batto any folder. -
(可选)将该文件夹添加到系统
PATH环境变量,以便在任意位置直接运行。
(Optional) Add that folder to yourPATHto run from anywhere.
双击 hash.bat 打开控制台窗口,会显示菜单。输入对应数字(或 a),然后将一个或多个文件拖入窗口,按 Enter 键即可。
Double‑click hash.bat to open the console with the menu. Enter the algorithm number (or a), then drag one or more files into the window and press Enter.
也可以直接传入文件路径(脚本会先询问算法):
You can also pass file paths directly (the script will ask for the algorithm first):
hash.bat C:\path\to\file1.txt D:\file2.pdf Num|Type
──────────────
0|exit
1|sha1
2|sha256
...
a|ALL
type: 2
Processing files (Algorithm: SHA256) ...
[myfile.txt] ...
Hash: 9f86d081884c7d659a9fe9590b4a3f4b6b8c7d9e...
-
脚本调用
powershell -Command,通常执行策略允许单条命令,无需额外设置。
The script usespowershell -Command– execution policy usually allows single commands without extra config. -
大文件计算哈希可能需要几秒钟,请耐心等待。
Hashing large files may take a few seconds – please be patient. -
MACTripleDES是一种密钥哈希,Get-FileHash默认使用空密钥,行为可能因环境而异。
MACTripleDESis a keyed hash;Get-FileHashuses an empty key by default (behaviour may vary).
本脚本采用 MIT 许可证,可自由使用、修改和分发。
This script is provided under the MIT License – feel free to use, modify, and distribute.