Class ProtectedDataHelper
- Namespace
- SunamoSecurity
- Assembly
- SunamoSecurity.dll
Provides methods to encrypt and decrypt strings using the Windows Data Protection API (DPAPI).
public static class ProtectedDataHelper
- Inheritance
-
ProtectedDataHelper
- Inherited Members
Methods
DecryptString(string, string, DataProtectionScope)
Decrypts a Base64-encoded encrypted string using DPAPI with the specified salt.
public static SecureString DecryptString(string salt, string encryptedText, DataProtectionScope dataProtectionScope = DataProtectionScope.CurrentUser)
Parameters
saltstringThe salt used as additional entropy for decryption.
encryptedTextstringThe Base64-encoded encrypted string to decrypt.
dataProtectionScopeDataProtectionScopeThe scope of data protection (current user or local machine).
Returns
- SecureString
The decrypted value as a SecureString. Returns an empty SecureString if decryption fails.
EncryptString(string, SecureString, DataProtectionScope)
Encrypts a SecureString using DPAPI with the specified salt.
public static string? EncryptString(string salt, SecureString secureString, DataProtectionScope dataProtectionScope = DataProtectionScope.CurrentUser)
Parameters
saltstringThe salt used as additional entropy for encryption.
secureStringSecureStringThe secure string to encrypt.
dataProtectionScopeDataProtectionScopeThe scope of data protection (current user or local machine).
Returns
- string
The encrypted string as a Base64-encoded value, or
nullif the input is null.