Table of Contents

Class SecureStringDecryptor

Namespace
ArcanaDevelopment.adTempus.Shared
Assembly
ArcanaDevelopment.adTempus.Shared.dll

This class assists the use of System.Security.SecureString instances.

public class SecureStringDecryptor : CriticalFinalizerObject
Inheritance
object
CriticalFinalizerObject
SecureStringDecryptor

Examples

You should use this class like in this example, and only for the shortest period of time necessary:

Rijndael aes = Rijndael.Create();
DeriveBytes db;
using (SecureStringDecryptor helper = new SecureStringDecryptor(secretString)) {
    db = new Rfc2898DeriveBytes(helper.Password, salt, 1024);
}
ICryptoTransform transform = aes.CreateEncryptor(db.GetBytes(16), aes.GenerateIV());

Remarks

Normally, the content of a System.Security.SecureString instance can only be read in unmnanaged code. This class decrypts the contents of a SecureString to a byte array, which is pinned in memory until it is released. When the dispose method is called, the array is zeroed-out.

Constructors

SecureStringDecryptor(SecureString)

Initializes a new instance of this class and decrypts the content of the System.Security.SecureString object into the Password array.

public SecureStringDecryptor(SecureString secret)

Parameters

NameTypeDescription
secret SecureString

Properties

Password

Returns the password that is stored in the System.Security.SecureString object that was passed to the constructor of this class.

public byte[] Password { get; }

Property Value

byte[]

Methods

Dispose()

Calls the Dispose(bool) method.

public void Dispose()

Dispose(bool)

Zeroes out and unpins the Password array.

protected void Dispose(bool disposing)

Parameters

NameTypeDescription
disposing bool

True, if called from the Dispose() methods, false if called from the destructor.

~SecureStringDecryptor()

Zeroes out and unpins the Password array.

protected ~SecureStringDecryptor()