Table of Contents

Interface IPasswordHasher

Namespace
MailFathom.Application.Access.Credentials
Assembly
MailFathom.Application.dll

Turns a password into the record a deployment stores, and judges a presented one against that record.

public interface IPasswordHasher

Remarks

The port exists so that no use case, no endpoint, and no command ever holds an opinion about which construction is in use, what its work parameters are, or how a salt is carried. All of that belongs to the one adapter behind this, and moving to a different construction is a change to that adapter plus the rehash path Verify(string, ReadOnlySpan<char>) already reports — never a change to anything that provisions or authenticates a credential.

Both members are synchronous and take a span, which is the shape the material has to be handled in. A password is read for the bounded duration of one hash or one verification and is never copied or retained by an implementation; a task-returning signature would put it behind an await, where the caller can no longer say when the buffer stops being read. What the span points at is the caller's, and on both of MailFathom's paths it is a string that nothing can wipe — so what a span buys here is a bounded reading rather than an erasure, and no implementation may promise the second. Hashing is deliberately expensive — that is the point of an adaptive construction — so a caller on a request path spends that cost knowingly rather than being offered a way to hide it.

The stored representation is opaque text to every caller. It carries its own algorithm identity, version, work parameters, and random salt, so a record written by an earlier release is self-describing and no column beside it has to be kept in step.

Methods

Hash(ReadOnlySpan<char>)

Produces the record to store for one password.

HashDecoy()

Produces a record no password matches, for comparing against a username this deployment holds nothing for.

Verify(string, ReadOnlySpan<char>)

Judges a presented password against a stored record.