AW: VBA oder PS
11.12.2019 10:42:16
Fennek
Hallo,
am einfachsten ist die Powershell-Console zu öffnen (Win10: rechts-klick auf Win-Symbol) und dort den Befehl eintippen und das Ergebnis mit copy/paste übertragen.
Oder den Code in eine *.ps1 Datei speichern und in VBA mit "Shell" aufrufen.
Oder diesen VBA-Code versuchen:
'https://stackoverflow.com/questions/36328530/how-to-generate-md5-hashes-for-large-files-with- _
vba
Public Function ComputeMD5(byval filepath As String) As String
Dim svc As Object, md5$, offset&, length&, i&, hFile
Dim hash() As Byte, block(0 To 31743) As Byte
' open the file
hFile = FreeFile
Open filepath For Binary Access Read As hFile Len = 31744
length = LOF(hFile)
' create the service
Set svc = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")
' compute each block
For i = 1 To length \ 31744
Get hFile, offset + 1, block
offset = offset + svc.TransformBlock(block, 0, 31744, block, 0)
Next
' compute the final block
If length - offset Then Get hFile, offset + 1, block
svc.TransformFinalBlock block, 0, length - offset
hash = svc.hash
' free the file and the service
svc.Clear
Close hFile
' convert to an hexa string
md5 = String(32, "0")
For i = 0 To 15
Mid$(md5, i * 2 + (hash(i) > 15) + 2) = Hex(hash(i))
Next
' return the md5
ComputeMD5 = UCase(md5)
End Function
mfg