0

I have created Hash code of an .iso file using fciv.exe. I have used MD5 and SHA1 algorithm. Then I found Get-filehash -Path "c:\MyProject.iso" -Algorithm Sha1 cmdlet in PowerShell, as it is very easy I used that.

But both the tools created different hash code. Hash algorithms should be unique across all the tools. At least that's what my understanding is - am I right? Or it is an expected behavior?

Update: I have taken a sample file and created hash value for that using fciv.exe and also using Powershell.

Fciv.exe created following Sha1

6d9Rar2xh+B5/eEE96pO15EDji0=

Powershell created following Sha1

E9DF516ABDB187E079FDE104F7AA4ED791038E2D
Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230
  • Perhaps you could post the hash codes that were generated? – Enigmativity Sep 24 '15 at 05:05
  • what do you mean? [Get-filehash](https://technet.microsoft.com/en-us/library/dn520872.aspx) requires you specify which algorithm to use, so: how did you actually use it? Did you compare the same file using "your" md5 computer, and Get-filehash set to md5, and then the same for sha1? How did they differ? If you make a .txt file with content "test", what are the prints you're getting? – Mike 'Pomax' Kamermans Sep 24 '15 at 05:05

1 Answers1

2

It is the same hash code, but Fciv.exe show it as BASE64 string, while Get-FileHash show it as HEX string:

$Hash=233,223,81,106,189,177,135,224,121,253,225,4,247,170,78,215,145,3,142,45
[Convert]::ToBase64String($Hash)
# 6d9Rar2xh+B5/eEE96pO15EDji0=
[BitConverter]::ToString($Hash)-replace'-'
# E9DF516ABDB187E079FDE104F7AA4ED791038E2D

With this piece of code you can add BASE64 representation of hash code to Get-FileHash output:

Get-FileHash FileName.iso|
Select-Object Algorithm,
              @{Name='HashHex';Expression='Hash'},
              @{Name='HashBase64';Expression={
                  [Convert]::ToBase64String(@(
                      $_.Hash-split'(?<=\G..)(?=.)'|
                      ForEach-Object {[byte]::Parse($_,'HexNumber')}
                  ))
              }},
              Path
user4003407
  • 21,204
  • 4
  • 50
  • 60
  • @PetSerAI How to convert ,you are using some Hard coded hash value and doing it. When i assign Get-filehash result into a variable i am unable to convert it – Samselvaprabu Sep 24 '15 at 07:26