Why do I get a different SHA1 hash between Powershell and 32bit-Python on a system DLL? -


i'm trying calculate sha1 hash values in python against binary files later comparison. make sure things working, used several methods check validity of result. and, i'm glad did. powershell , python return different values. 7zip's sha1 function agrees powershell's results , microsoft's fciv agrees python's results.

python:

import hashlib open("c:\\windows\\system32\\wbem\\wmiutils.dll", "rb") f:      print(hashlib.sha1(f.read()).hexdigest()) 

powershell:

ps c:\> get-filehash c:\windows\system32\wbem\wmiutils.dll -algorithm sha1 

results:

python: d25f5b57d3265843ed3a0e7b6681462e048b29a9 powershell: b8c757ba70f6b145ad191a1b09c225fba2bd55fb 

edit: 32-bit python , 64-bit powershell against system32 dll. problem. have homework basically, 32-bit , 64-bit applications receive different file , thus, different hash results. launched 64-bit python , ran exact same code against dll , 64-bit powershell process. received consistent results when running both processes 32-bit.

edit2: found resource explains things bit. @ least helped me understand what's going on: https://www.sepago.com/blog/2008/04/20/windows-x64-all-the-same-yet-very-different-part-7-file-system-and-registry

this happening because running 32bit version of python , accessing system dll -- windows magically redirects 32bit version of dll, while powershell running 64bit process , sees 64bit version of dlls.

i not sure if glad know or saddened it.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -