Show / Hide Table of Contents

Class PasswordStorage

Contains methods for creating Salty Hashes of passwords that are safe to store, as well as verifying a password’s validity.

Inheritance
object
PasswordStorage
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Helpers
Assembly: MCART.Security.dll
Syntax
public static class PasswordStorage

Methods

| Edit this page View Source

CreateHash(IPasswordStorage, SecureString)

Creates a secure hash for storing a password.

Declaration
public static byte[] CreateHash(IPasswordStorage algorithm, SecureString password)
Parameters
Type Name Description
IPasswordStorage algorithm

Key‑derivation algorithm to use.

SecureString password

Password to store.

Returns
Type Description
byte[]

A byte array that can be safely stored in a database and later used to verify a password. The array includes information about the derivation algorithm used, as well as all of its configuration parameters.

| Edit this page View Source

CreateHash<T>(SecureString)

Creates a secure hash for storing a password.

Declaration
public static byte[] CreateHash<T>(SecureString password) where T : IPasswordStorage, new()
Parameters
Type Name Description
SecureString password

Password to store.

Returns
Type Description
byte[]

A byte array that can be safely stored in a database and later used to verify a password.

Type Parameters
Name Description
T

Key‑derivation algorithm to use.

| Edit this page View Source

RegisterAlgorithm(IPasswordStorage)

Registers an algorithm instance to provide password hashing and verification services.

Declaration
public static void RegisterAlgorithm(IPasswordStorage alg)
Parameters
Type Name Description
IPasswordStorage alg

Algorithm instance to register.

| Edit this page View Source

RegisterAlgorithm<T>()

Registers an algorithm to provide password hashing and verification services.

Declaration
public static void RegisterAlgorithm<T>() where T : IPasswordStorage, new()
Type Parameters
Name Description
T

Type of algorithm to be registered. It must have a public parameterless constructor.

| Edit this page View Source

VerifyPassword(SecureString, byte[])

Verifies a password.

Declaration
public static bool? VerifyPassword(SecureString password, byte[] hash)
Parameters
Type Name Description
SecureString password

Password to verify.

byte[] hash

Hash to compare against. It must contain information about the key‑derivation algorithm used, as well as any required configuration values.

Returns
Type Description
bool?

true if the password is valid, false otherwise, or null if an error occurs during verification (e.g., due to tampering).

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX