Table of Contents

Class ExcelPassword

Namespace
ExcelReader.Core.Reader
Assembly
ExcelReader.Core.dll

A workbook password. Deliberately a class rather than a record: a record's synthesized ToString would print the password, and this type is held by ExcelReaderOptions, which is a record — so one logger.LogDebug("{Options}", options) would leak it. ToString() below is what makes that safe.

public sealed class ExcelPassword
Inheritance
ExcelPassword
Inherited Members

Remarks

On wiping secrets, plainly: a password that reaches this type as a string cannot be wiped — .NET strings are immutable, movable by the GC, and possibly interned. This type does not pretend otherwise, and deliberately does not use SecureString, which is deprecated and only ever protected anything on Windows. What the library actually does is zero the UTF-16 buffer it allocates during key derivation and zero the derived key when the reader is disposed — that key, not the password, is what lives in memory for the reader's lifetime.

Constructors

ExcelPassword(ReadOnlySpan<char>)

Initializes a new instance from a character span, for callers avoiding a string.

public ExcelPassword(ReadOnlySpan<char> password)

Parameters

password ReadOnlySpan<char>

The password characters, copied into this instance.

ExcelPassword(string)

Initializes a new instance from a string.

public ExcelPassword(string password)

Parameters

password string

The password. Must not be null.

Methods

FromString(string)

Creates an ExcelPassword from a string. Named alternative to the implicit conversion.

public static ExcelPassword FromString(string password)

Parameters

password string

The password.

Returns

ExcelPassword

ToString()

Returns a redacted placeholder, never the password itself.

public override string ToString()

Returns

string

Operators

implicit operator ExcelPassword(string)

Converts a string to an ExcelPassword.

public static implicit operator ExcelPassword(string password)

Parameters

password string

The password.

Returns

ExcelPassword