/
Create SHA-256 Hash for File in PowerShell
Create SHA-256 Hash for File in PowerShell
The following commands allow you to create the SHA-256 hash for a file, in Base 64 format, in PowerShell. This can be compared to the hash stored by Foray ADAMSĀ® for a file, less the āSHA256ā prefix.
PowerShell - all versions
[System.Convert]::ToBase64String([byte[]] -split ((Get-FileHash "<FILE_PATH>").Hash -replace '..', '0x$& '))
Example:
[System.Convert]::ToBase64String([byte[]] -split ((Get-FileHash "C:\Temp\MyFile.txt").Hash -replace '..', '0x$& '))
Ā
PowerShell 7.1+
[System.Convert]::ToBase64String([System.Convert]::FromHexString((Get-FileHash "<FILE_PATH>").Hash))
Example:
[System.Convert]::ToBase64String([System.Convert]::FromHexString((Get-FileHash "C:\Temp\MyFile.txt").Hash))
Ā
Sample Output
YvPeMc0vFBGrP5v/KIrXAx6/qbR5WiMmSpt5YUOrbIo=
Ā
Related content
How to Generate a Self Signed Certificate
How to Generate a Self Signed Certificate
More like this
How to setup Powershell
How to setup Powershell
More like this
How to Get Directory Size (PowerShell command line)
How to Get Directory Size (PowerShell command line)
More like this
Delete a directory in Backblaze B2
Delete a directory in Backblaze B2
More like this
Find a Product's UpgradeCode from the Command Line
Find a Product's UpgradeCode from the Command Line
More like this
How to download Photoshop CC 2015 32-bit
How to download Photoshop CC 2015 32-bit
More like this
Ā© 2023 Foray, LLC - All Rights Reserved