IPWorks Encrypt 2020 PHP Edition

Questions / Feedback?

Unprotect Method

Unprotects the data.

Object Oriented Interface

public function doUnprotect();

Procedural Interface

ipworksencrypt_dpapi_do_unprotect($res);

Remarks

Unprotect unprotects the specified data.

The class supports unprotecting data using either the classic DPAPI or CNG DPAPI implementation. The use of UseCNG determines which implementation is used. The list of applicable properties differs depending on whether CNG DPAPI is being used.

When using classic DPAPI (UseCNG is False), the following optional properties are applicable:

When using CNG DPAPI (UseCNG is True), the following properties are applicable:

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

Code Example (Classic DPAPI - UseCNG is False)


//Protect
Dpapi dpapi = new Dpapi();
dpapi.InputMessage = "test";
dpapi.Protect();
byte[] protectedData = dpapi.OutputMessageB;

//Unprotect
dpapi = new Dpapi();
dpapi.InputMessageB = protectedData;
dpapi.Unprotect();
Console.WriteLine(dpapi.OutputMessage); //outputs "test"

Code Example (CNG DPAPI - UseCNG is True)


//Protect
Dpapi dpapi = new Dpapi();
dpapi.UseCNG = true;
dpapi.ProtectionDescriptor = "LOCAL=user";
dpapi.InputMessage = "test";
dpapi.Protect();
byte[] protectedData = dpapi.OutputMessageB;

//Unprotect
dpapi = new Dpapi();
dpapi.UseCNG = true;
dpapi.InputMessageB = protectedData;
dpapi.Unprotect();
Console.WriteLine(dpapi.OutputMessage); //outputs "test"

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Encrypt 2020 PHP Edition - Version 20.0 [Build 8155]