Table of Contents

Class DpapiHelper

Namespace
ItTiger.TigerQuery.Core.Encryption
Assembly
ItTiger.TigerQuery.Core.dll
Provides current-user Windows DPAPI encryption helpers using UTF-8 text and Base64-encoded protected values.
public static class DpapiHelper
Inheritance
DpapiHelper
Inherited Members

Methods

Decrypt(string)

Attempts to decrypt a Base64-encoded current-user DPAPI value.
public static string Decrypt(string encrypted)

Parameters

encrypted string
The value produced by Encrypt(string).

Returns

string
The decrypted UTF-8 text, or an empty string when decoding or unprotection fails.

Exceptions

PlatformNotSupportedException
The current platform is not Windows.

Encrypt(string)

Encrypts text for the current Windows user.
public static string Encrypt(string plain)

Parameters

plain string
The plain text to protect.

Returns

string
A Base64-encoded DPAPI value.

Exceptions

PlatformNotSupportedException
The current platform is not Windows.

TryDecrypt(string, out string)

Tries to decrypt a Base64-encoded current-user DPAPI value.
public static bool TryDecrypt(string encrypted, out string plain)

Parameters

encrypted string
The protected value to decrypt.
plain string
Receives non-empty decrypted text on success, or an empty string on failure.

Returns

bool
true when a non-empty value is decrypted; otherwise false.

Remarks

This method returns false rather than throwing for platform and decryption failures.

TryEncrypt(string, out string)

Tries to encrypt text for the current Windows user.
public static bool TryEncrypt(string plain, out string encrypted)

Parameters

plain string
The plain text to protect.
encrypted string
Receives the Base64-encoded protected value on success, or an empty string on failure.

Returns

bool
true on success; otherwise false.

Remarks

This method returns false rather than throwing for platform and encryption failures.