Class SecureStringHelper
- Namespace
- SunamoSecurity
- Assembly
- SunamoSecurity.dll
Provides conversion methods between SecureString and regular strings, and convenience methods for encrypting and decrypting strings.
public static class SecureStringHelper
- Inheritance
-
SecureStringHelper
- Inherited Members
Methods
CreateCryptDelegates()
Creates a CryptDelegates instance with the default encryption and decryption methods.
public static CryptDelegates CreateCryptDelegates()
Returns
- CryptDelegates
A new CryptDelegates with DecryptString(string, string) and EncryptString(string, string) as delegates.
DecryptString(string, string)
Decrypts an encrypted string using DPAPI with the specified salt.
public static string? DecryptString(string salt, string encryptedText)
Parameters
saltstringThe salt used as additional entropy for decryption.
encryptedTextstringThe Base64-encoded encrypted string to decrypt.
Returns
- string
The decrypted plain text string, or
nullif decryption fails.
EncryptString(string, string)
Encrypts a plain text string using DPAPI with the specified salt.
public static string? EncryptString(string salt, string text)
Parameters
saltstringThe salt used as additional entropy for encryption.
textstringThe plain text string to encrypt.
Returns
- string
The encrypted string as a Base64-encoded value, or
nullif encryption fails.
ToInsecureString(SecureString)
Converts a SecureString to a regular string using Unicode global allocation.
public static string? ToInsecureString(SecureString secureString)
Parameters
secureStringSecureStringThe secure string to convert.
Returns
- string
The plain text representation of the secure string, or
nullif conversion fails.
ToInsecureString2(SecureString)
Converts a SecureString to a regular string using BSTR marshalling.
public static string ToInsecureString2(SecureString secureString)
Parameters
secureStringSecureStringThe secure string to convert.
Returns
- string
The plain text representation of the secure string.
ToSecureString(string)
Converts a regular string to a SecureString using NetworkCredential.
public static SecureString ToSecureString(this string text)
Parameters
textstringThe string to convert to a secure string.
Returns
- SecureString
A SecureString containing the value of the input string.
ToSecureString2(string)
Converts a regular string to a SecureString by appending each character individually.
public static SecureString ToSecureString2(string text)
Parameters
textstringThe string to convert to a secure string.
Returns
- SecureString
A read-only SecureString containing the value of the input string.