# MD5 calculator in powershell

## Compute the hash value

Get-FileHash cmdlet allows easily to compute the hash value for a file since PowerShell version 4.0. The acceptable values for algorithm are: SHA1, SHA256, SHA384, SHA512, MD5. More about Get-FileHash you can read in official documentation.
Simplest way to calculate md5 hash value for a file is to use command:

I decided to build simple MD5 calculator using Powershell.

## MD5 calcuator

Powershell GUI

First I created a menu

### Variables

I used few variables which need to be provided by user:

• $FilePath - for the file source • $FolderPath - for folder source
• $Output - text file output location ### Options I added four options like: 1. MD5 for single file, output in console Get-FileHash$FilePath -Algorithm MD5 | Format-List
2. MD5 for single file, output in text file Get-FileHash $FilePath -Algorithm MD5 | Format-List >$Output\MD5.txt
3. MD5 for all files in folder, output in console Get-ChildItem $FolderPath | Get-FileHash -Algorithm MD5 | Format-List 4. MD5 for all files in folder, output in text file Get-ChildItem$FolderPath | Get-FileHash -Algorithm MD5 | Format-List > $Output\MD5.txt ### Progress info I also wanted to display some information about work in progress so I added three text variables • $Activity = "Calculating MD5 Hash Value"
• $Id = 1 • $Task = "Please wait"

and part of code to display progress info during the hash value is calculated

## Whole script

And the full code looks like below

### Usage

All you need is to copy everything and save as MD5Calculator.ps1 then run with Powershell and follow instructions on the screen. By changing the -Algorithm parameter you can simply create a calculator for other algorithms.