Usando a Função GET-filehash eu tive um resultado diferente do mesmo script, é normal?
function Get-SHA256 {
param (
$Filename
)
$Conteudo = Get-Content $Filename
$filebyte = [System.Text.Encoding]::UTF8.GetBytes($Conteudo)
$sha256 = New-Object System.Security.Cryptography.SHA256Managed
$hash256 = $sha256.ComputeHash($filebyte)
$fullex = New-Object System.Text.StringBuilder
foreach ($byte in $hash256) {
$hex = $byte.ToString("X2")
$fullex.Append($hex) > $null
}
$fullex.ToString()
}
$arquivo = "C:\temp\Scripts\hs-fuctions.ps1"
$hashDoArquivo = Get-SHA256 $arquivo
Write-host "O hash do arquivo $arquivo eh $hashDoArquivo" -BackgroundColor Red -ForegroundColor Yellow
saida PS C:\Temp\Scripts> c:\Temp\Scripts\get-SHA256.ps1 O hash do arquivo C:\temp\Scripts\hs-fuctions.ps1 eh E4096D0ED9C845671AB4E88CBD372A57D639D5AA9FA63FB657679CCC9C54C455
get-filehash PS C:\Temp\Scripts> Get-FileHash .\hs-fuctions.ps1
Algorithm Hash Path
SHA256 EE9B9FFFC6171C89C8941B612B5388855590DD144BF6B623EE32F782CBAD7373 C:\Temp\Scripts\hs-fuctions.ps1