Table of Contents

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

salt string

The salt used as additional entropy for decryption.

encryptedText string

The Base64-encoded encrypted string to decrypt.

Returns

string

The decrypted plain text string, or null if 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

salt string

The salt used as additional entropy for encryption.

text string

The plain text string to encrypt.

Returns

string

The encrypted string as a Base64-encoded value, or null if encryption fails.

ToInsecureString(SecureString)

Converts a SecureString to a regular string using Unicode global allocation.

public static string? ToInsecureString(SecureString secureString)

Parameters

secureString SecureString

The secure string to convert.

Returns

string

The plain text representation of the secure string, or null if conversion fails.

ToInsecureString2(SecureString)

Converts a SecureString to a regular string using BSTR marshalling.

public static string ToInsecureString2(SecureString secureString)

Parameters

secureString SecureString

The 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

text string

The 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

text string

The string to convert to a secure string.

Returns

SecureString

A read-only SecureString containing the value of the input string.