Last active
August 29, 2015 14:03
-
-
Save mitchelldavis/33570d3d31df70a76f9d to your computer and use it in GitHub Desktop.
Get SHA256 hash of a file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string] $file = $(throw 'a filename is required'), | |
[string] $algorithm = 'sha256' | |
) | |
$fileStream = [system.io.file]::openread((resolve-path $file)) | |
$hasher = [System.Security.Cryptography.HashAlgorithm]::create($algorithm) | |
$hash = $hasher.ComputeHash($fileStream) | |
$fileStream.close() | |
$fileStream.dispose() | |
[system.bitconverter]::tostring($hash).Replace("-","").ToLower() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment