VeriHash is a PowerShell 7+ tool for computing and verifying SHA256 file hashes.
π PowerShell 7 is a modern, open-source, cross-platform edition of PowerShell. π It can be safely installed alongside the built-in Windows PowerShell without causing conflicts.
Note: PowerShell 7 (also known as PowerShell Core) is different from the older Windows PowerShell (version 5.1) that comes pre-installed with Windows 10/11.
- Why PowerShell 7?
- Features
- Requirements
- Execution Policy (Optional)
- Installation
- Usage Examples
- Use Cases
- Speed
- Adding VeriHash to Your PowerShell Profile
- Contributing
- License
- π Modern and Cross-Platform: PowerShell 7 runs on Windows, macOS, and Linux, making VeriHash more widely usable.
- π§βπ» Active Development: PowerShell 7 receives regular updates, performance improvements, and new features.
- π No Conflict with Windows PowerShell: Installing PowerShell 7 does not remove or break the existing Windows PowerShell. Both can coexist, allowing you to explore this tool without losing any native capabilities.
- π€ΉπΌ Cross-Platform: Any platform PowerShell 7 is supported. Tested with Win 10/11, Debian 12, MacOS 12.
If you're new to PowerShell 7, here are some quick pointers:
-
Installation is Simple: On Windows, you can install PowerShell 7 from the Microsoft Store or download the installer from the official GitHub releases page. On macOS or Linux, you can follow the straightforward instructions provided in the PowerShell Documentation.
-
Running VeriHash with PowerShell 7: After installing PowerShell 7, open a PowerShell 7 console (often listed as
pwsh
on Windows). Navigate to the directory containingVeriHash.ps1
and run:.\VeriHash.ps1
See also: [[# Adding VeriHash to Your PowerShell Profile]] for an easy way to just use it from anywhere like:
verihash filename.ext
-
Secure: PowerShell 7 supports execution policies and script signing, just like the older Windows PowerShell. You remain in control of what scripts you run. VeriHash itself is a simple hashing tool with transparent source code, allowing you to inspect it before running if you like.
- π FAST
- SHA256 Hashing: Compute SHA256 hashes for any file.
- Verification from
.sha2_256
: Verify files using automatically generated.sha2_256
files. - Input Hash Comparison: Compare a computed hash against a provided input hash.
- Interactive File Selection (Windows): If no file is given, easily select one via a file dialog.
- PowerShell 7+ is required to run VeriHash.
- Works on Windows and non-Windows platforms. On non-Windows, you'll be prompted to enter a file path manually instead of using a dialog.
-
On some Windows systems, you may need to allow running this script. In PowerShell 7, run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
This command allows locally created scripts like VeriHash to run without being blocked while still maintaining some security. You can always revert this by running Set-ExecutionPolicy Default
.
Install gh cli (fastest/easiest/most secure)
π‘ gh
CLI method
gh auth login
gh repo clone arcticpinecone/pwsh7-VeriHash VeriHash
-
Clone the repository:
git clone https://github.com/arcticpinecone/pwsh7-VeriHash VeriHash
-
Navigate into the directory:
cd VeriHash
-
Run
VeriHash.ps1
in PowerShell:.\VeriHash.ps1
If you provide just a file path, VeriHash
will compute and display its SHA256 hash.
If the hash is SHA256 (the default), it also creates a .sha2_256
file in the same directory.
.\VeriHash.ps1 "C:\path\to\yourfile.exe"
.\VeriHash.ps1 "/mnt/c/path/to/yourfile.exe"
If you run VeriHash
on a .sha2_256
file:
.\VeriHash.ps1 "C:\path\to\yourfile.exe.sha2_256"
.\VeriHash.ps1 "/mnt/c/path/to/yourfile.exe.sha2_256"
It will verify that yourfile.exe
matches the stored hash.
If the referenced file isn't found or the hash doesn't match, you'll be notified.
Provide both the file and a known-good hash to verify. Use the -hash
parameter!
.\VeriHash.ps1 "C:\path\to\yourfile.exe" -hash "ABC123456"
.\VeriHash.ps1 "/mnt/c/path/to/yourfile.exe" -hash "ABC123456"
VeriHash
will display whether the computed hash matches the input hash.
Just run:
.\VeriHash.ps1
If no path is given, on Windows you can select a file using a GUI dialog. On other systems, you'll be prompted to type provide the path.
-
π¬ Software Integrity Checks: Downloaded a new piece of software? Compute its SHA256 hash and compare it to the vendor-provided hash.
-
π Automated Verification in CI/CD: Integrate VeriHash in your build pipeline to verify that build artifacts haven't been tampered with.
-
πΎ Backup Integrity Checks: Generate
.sha2_256
files for backups and run periodic checks to ensure no corruption over time.
Hashing speeds depend on your hardware.
- On SSDs, hashing can exceed 190 MB/second (~40 seconds for 8GB files).
- While HDDs may hash at ~93 MB/second (~88 seconds for 8GB files).
- Smaller files are processed almost instantly, while 10GB files may take ~1-2 minutes.
-
SSD Speeds:
5 seconds for 1GB, 40 seconds for 8GB, 53 seconds for 10GB. -
HDD Speeds:
11 seconds for 1GB, 88 seconds for 8GB, 110 seconds for 10GB.
π‘ Tip:
- For large files, feel free to grab a β, π΅, or stretch your legs. π€Έ
- For small files (<500MB), expect the process to complete almost instantly. β‘
You can add VeriHash
to your PowerShell $PROFILE
for quick and easy access from any directory. This example demonstrates how to create a custom function that wraps VeriHash.ps1
and accepts parameters.
-
Find Your PowerShell Profile Path: Open PowerShell 7 and run:
$PROFILE
This will return the path to your PowerShell profile file, typically:
C:\Users\<YourUsername>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
-
Edit Your Profile: Open the profile file in a text editor (create it if it doesnβt exist):
if (-not (Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force } notepad $PROFILE
-
Add a Custom
verihash
Function: Add the following function, updating the path toVeriHash.ps1
:function verihash { param ( [string]$FilePath, [string]$Hash ) & "C:\Users\<YourUsername>\source\repos\VeriHash\VeriHash.ps1" $FilePath -hash $Hash }
-
Save and Reload Your Profile: Save the file and reload your profile:
. $PROFILE
-
Usage: Now you can run
verihash
from anywhere:verihash -FilePath "C:\path\to\file" -Hash "ABC123..."
Or simply:
verihash "C:\path\to\file"
For macOS/Linux, the steps are similar but paths differ. Use the following steps:
-
Find your profile path:
$PROFILE
Typical path:
~/.config/powershell/Microsoft.PowerShell_profile.ps1
The
$PROFILE
variable in PowerShell always points to the default path for the current user's profile file, whether or not the file (or its parent directories) actually exists. PowerShell assumes this file will eventually exist if the user decides to customize their environment. -
Create the Directory (If Needed) If the parent directory doesnβt exist, create it:
mkdir -p (Split-Path -Parent $PROFILE)
-
Edit or create your profile:
if (-not (Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force } nano $PROFILE
-
Add the custom
verihash
function:function verihash { param ( [string]$FilePath, [string]$Hash ) & "/path/to/VeriHash.ps1" $FilePath -hash $Hash }
e.g.
/home/user/GitHub/VeriHash/VeriHash.ps1
-
Save and reload your profile:
. $PROFILE
-
Use
verihash
as shown above.
Feel free to open issues, submit pull requests, or suggest enhancements.
Creative Commons Attribution-ShareAlike 4.0 International Public License