> For the complete documentation index, see [llms.txt](https://www.pinvoke.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pinvoke.dev/crypt32/cryptprotectdata.md).

# CryptProtectData

```csharp
[DllImport("CRYPT32.dll", ExactSpelling = true, SetLastError = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
public static extern unsafe BOOL CryptProtectData(
    CRYPT_INTEGER_BLOB* pDataIn,
    PCWSTR szDataDescr,
    [Optional] CRYPT_INTEGER_BLOB* pOptionalEntropy,
    [Optional] void* pvReserved,
    [Optional] CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,
    uint dwFlags,
    CRYPT_INTEGER_BLOB* pDataOut);

```

[CRYPT\_INTEGER\_BLOB](/cryptography/crypt_integer_blob.md)

Valid `dwFlags`:

```csharp
public const uint CRYPTPROTECT_LOCAL_MACHINE = 4U;
public const uint CRYPTPROTECT_UI_FORBIDDEN = 1U;
public const uint CRYPTPROTECT_AUDIT = 16U;
```
