Вот несколько способов вычисления контрольной суммы MD5 с помощью PowerShell:
Метод 1: использование командлета Get-FileHash
$filePath = "C:\Path\to\file.txt"
$md5Hash = (Get-FileHash -Path $filePath -Algorithm MD5).Hash
Write-Host "MD5 Checksum: $md5Hash"
Метод 2: использование пространства имен System.Security.Cryptography.NET Framework
$filePath = "C:\Path\to\file.txt"
$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$fileStream = [System.IO.File]::OpenRead($filePath)
$md5Hash = [System.BitConverter]::ToString($md5.ComputeHash($fileStream))
$fileStream.Close()
Write-Host "MD5 Checksum: $md5Hash"
Метод 3: использование командлета Get-Contentи расчет контрольной суммы MD5 вручную
$filePath = "C:\Path\to\file.txt"
$fileContent = Get-Content -Path $filePath -Raw
$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$md5Hash = [System.BitConverter]::ToString($md5.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($fileContent)))
Write-Host "MD5 Checksum: $md5Hash"