Aether Utilities Aether Utilities
Aether Utilities Aether Utilities
DocFX + Singulink = ♥

Search Results for

    Edit this page

    Class PasswordRule

    Namespace
    AetherUtils.Core.Security.Passwords
    Assembly
    AetherUtils.Core.dll
    Represents a password rule with various options. A password rule should be built using the Rule Builder factory: IPasswordRuleBuilder.

    This class contains methods to parse and save a password rule to/from a file as well as a string.

    A password can be validated against a rule using Validate(string).
    public sealed class PasswordRule
    Inheritance
    object
    PasswordRule
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    Extension Methods
    TypeExtensions.CanSerializeJson<T>(T)
    TypeExtensions.CanSerializeXml<T>(T)
    TypeExtensions.SerializeJson<T>(T)
    TypeExtensions.SerializeXml<T>(T)

    Properties

    PasswordRules

    Get the string representing this password rule.
    public string PasswordRules { get; }

    Property Value

    string

    Methods

    FromEncryptedString(string, string)

    Parse a password rule from an encrypted string.
    public static PasswordRule FromEncryptedString(string encrypted, string passphrase)

    Parameters

    encrypted string
    The encrypted password rule to parse.
    passphrase string
    The passphrase used for decryption.

    Returns

    PasswordRule
    The PasswordRule or null if parsing failed.

    GetValidPassword()

    Get a random, cryptographically strong password that follows the password rule.
    public string GetValidPassword()

    Returns

    string
    A new, random password that adheres to the password rule created.

    New()

    Start building the password rule.
    public static IPasswordRuleBuilder New()

    Returns

    IPasswordRuleBuilder
    The builder instance.

    Parse(string)

    Parse a password rule from a Json string.
    public static PasswordRule Parse(string json)

    Parameters

    json string
    The password rule as Json to parse.

    Returns

    PasswordRule
    The PasswordRule or null if parsing failed.

    ParseFromFileAsync(string, string)

    Parse an encrypted password rule from a file.
    public static Task<PasswordRule?> ParseFromFileAsync(string filePath, string passphrase)

    Parameters

    filePath string
    The path to the file to load; can contain Windows path variables (i.e., %temp%)
    passphrase string
    The passphrase used for decryption. Should be the same as the one used for encryption.

    Returns

    Task<PasswordRule>
    The PasswordRule or null if parsing failed.

    SaveToFileAsync(string, string)

    Save the encrypted password rule to a file.
    public Task<bool> SaveToFileAsync(string filePath, string passphrase)

    Parameters

    filePath string
    The path to the file to save; can contain Windows path variables (i.e., %temp%)
    passphrase string
    The passphrase used for encryption.

    Returns

    Task<bool>
    true if the password rule saved successfully; false otherwise.

    ToEncryptedString(string)

    Get an encrypted string representing this password rule.
    public string ToEncryptedString(string passphrase)

    Parameters

    passphrase string
    The passphrase used for encryption.

    Returns

    string
    A base64 string representing the password rule.

    ToString()

    Get the Json string representing this password rule.
    public override string ToString()

    Returns

    string

    Validate(string)

    Validate a password against this rule.
    public List<IValidationFailure> Validate(string password)

    Parameters

    password string
    The password to validate.

    Returns

    List<IValidationFailure>
    A list of IValidationFailure containing the reasons the password failed to validate. If this list is empty, the password validated successfully.
    (c) 2024 Ethan Hann. All rights reserved.