(data, entropy=None, flags=gdef.CRYPTPROTECT_UI_FORBIDDEN)
| 5 | |
| 6 | |
| 7 | def 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 | |
| 22 | def unprotect(data, entropy=None, flags=gdef.CRYPTPROTECT_UI_FORBIDDEN): |
nothing calls this directly
no test coverage detected