MD5-Hash für eine Datei bestimmen

Ausgehend von einer komplexeren Funktion, die mir bereitgestellt wurde, hier ein Beispiel für die Berechnung von MD5-Hashes in Powershell:

[System.IO.FileInfo] $file = "c:\hallo.txt"
    $cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider];
    $hashAlgorithm = new-object $cryptoServiceProvider
    $stream = $file.OpenRead();
    $hashByteArray = $hashAlgorithm.ComputeHash($stream);
    $stream.Close();
    return [string]$hashByteArray;

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website