the following uses the System.Security.Cryptography
namespace from c#
and implements the unprotect
method from the ProtectedData
class
byte[] output = ProtectedData.Unprotect(input, null, DataProtectionScope.LocalMachine);
I'm trying to access my pc's HKEY_LOCALMACHINE registry with python because theres a key somewhere in it that i need (to read), in order to decrypt a file. I read the docs but I'm still just not sure what method I should use for that purpose
aReg = winreg.ConnectRegistry(None, HKEY_LOCAL_MACHINE)
I'm not quite sure what comes next so any help would be appreciated.
Turns out I needed this: https://learn.microsoft.com/en-us/windows/win32/api/dpapi/nf-dpapi-cryptunprotectdata
import win32crypt
#open binary file in readmode
filecontents = fileObject.read()
unecryptedFileContents = win32crypt.CryptUnprotectData(filecontents)