MCPcopy Create free account
hub / github.com/ELMERIKH/PyinMemoryPE / protect

Function protect

windows/crypto/dpapi.py:7–19  ·  view source on GitHub ↗
(data, entropy=None, flags=gdef.CRYPTPROTECT_UI_FORBIDDEN)

Source from the content-addressed store, hash-verified

5
6
7def protect(data, entropy=None, flags=gdef.CRYPTPROTECT_UI_FORBIDDEN):
8 in_blob = gdef.DATA_BLOB.from_string(data)
9 out_blob = gdef.DATA_BLOB()
10 if entropy is not None:
11 entropy = gdef.DATA_BLOB.from_string(entropy)
12 winproxy.CryptProtectData(in_blob, pOptionalEntropy=entropy, dwFlags=flags, pDataOut=out_blob)
13 encrypted_data = bytes(out_blob.data)
14 # https://docs.microsoft.com/en-us/windows/win32/api/dpapi/nf-dpapi-cryptprotectdata
15 # pDataOut: A pointer to a DATA_BLOB structure that receives the encrypted data.
16 # When you have finished using the DATA_BLOB structure, free its pbData member by calling the LocalFree function.
17 winproxy.LocalFree(out_blob.pbData)
18 del out_blob
19 return encrypted_data
20
21
22def unprotect(data, entropy=None, flags=gdef.CRYPTPROTECT_UI_FORBIDDEN):

Callers

nothing calls this directly

Calls 1

from_stringMethod · 0.45

Tested by

no test coverage detected