Replace Get-FileHash with MD5 code that works on PowerShell 3.

This commit is contained in:
Chris Church 2014-08-28 01:42:22 -04:00
parent 6e7773e9b8
commit 1b6ef9aa2e

View file

@ -53,8 +53,11 @@ Else
If ($get_md5 -and $result.stat.exists -and -not $result.stat.isdir)
{
$path_md5 = (Get-FileHash -Path $path -Algorithm MD5).Hash.ToLower();
Set-Attr $result.stat "md5" $path_md5;
$sp = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider;
$fp = [System.IO.File]::Open($path, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read);
$hash = [System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower();
$fp.Dispose();
Set-Attr $result.stat "md5" $hash;
}
Exit-Json $result;