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
encryptedstring- 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
plainstring- 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
encryptedstring- The protected value to decrypt.
plainstring- Receives non-empty decrypted text on success, or an empty string on failure.
Returns
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
plainstring- The plain text to protect.
encryptedstring- Receives the Base64-encoded protected value on success, or an empty string on failure.
Returns
Remarks
This method returns false rather than throwing for platform and encryption failures.