UnprotectAsync | unprotectAsync method

DataProtectionProvider.UnprotectAsync | unprotectAsync method

Asynchronously decrypts static data.

Syntax


dataProtectionProvider.unprotectAsync(data).done( /* Your success and error handlers */ );

Parameters

data

Type: IBuffer

Data to decrypt.

Return value

Type: IAsyncOperation<IBuffer>

Represents an asynchronous operation.

Remarks

You must call the DataProtectionProvider() constructor before calling this method.

For security descriptors and SDDL strings, you must set the enterprise authentication capability in the manifest. The enterprise authentication capability is restricted to Windows Store apps built with company accounts, and is subject to additional onboarding validation. You should avoid the enterprise authentication capability unless it is absolutely necessary. For more information, see Registering for a Windows Store developer account.

For example, the following SID and SDDL providers require the enterprise authentication capability:

  • "SID=S-1-5-21-4392301 AND SID=S-1-5-21-3101812"
  • "SDDL=O:S-1-5-5-0-290724G:SYD:(A;;CCDC;;;S-1-5-5-0-290724)(A;;DC;;;WD)"

These providers do not require the enterprise authentication capability:

  • "LOCAL=user"
  • "LOCAL=machine"
  • "WEBCREDENTIALS=MyPasswordName"
  • "WEBCREDENTIALS=MyPasswordName,myweb.com"

Examples

The following example shows how to decrypt static data that was previously protected by using the ProtectAsync function.


public async Task<String> SampleUnprotectData(
    IBuffer buffProtected,
    BinaryStringEncoding encoding)
{
    // Create a DataProtectionProvider object.
    DataProtectionProvider Provider = new DataProtectionProvider();

    // Decrypt the protected message specified on input.
    IBuffer buffUnprotected = await Provider.UnprotectAsync(buffProtected);

    // Execution of the SampleUnprotectData method resumes here
    // after the awaited task (Provider.UnprotectAsync) completes
    // Convert the unprotected message from an IBuffer object to a string.
    String strClearText = CryptographicBuffer.ConvertBinaryToString(encoding, buffUnprotected);

    // Return the plaintext string.
    return strClearText;
}


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Security.Cryptography.DataProtection
Windows::Security::Cryptography::DataProtection [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Security.Cryptography.DataProtection
Windows::Security::Cryptography::DataProtection [C++]

Metadata

Windows.winmd

See also

DataProtectionProvider

 

 

Show:
© 2017 Microsoft