namespace Galaeth.Services.Interfaces; /// /// Cryptographic operations. /// public interface ICryptographyService { /// /// Generate a random salt. /// /// Size of the salt to generate - if omitted, will use PwdHashSettings:HashSize config. /// Byte array containing the generated salt. byte[] GenerateSalt(int? size = null); /// /// Hash a password string with the accompanying salt. /// /// The password to hash. /// The salt to use. /// A byte array of PwdHashSettings:HashSize config size of the password. byte[] HashPassword(string password, byte[] salt); /// /// Verify that the given password matches the password hash and salt. /// /// The password to test. /// The password's accompanying salt. /// The password hash to test again. /// True if verified, false otherwise. bool VerifyPassword(string password, byte[] salt, byte[] passwordHash); /// /// Verify that the given password matches the password hash and salt. /// /// The password to test. /// The password's base64 encoded accompanying salt. /// The password base64 hash to test again. /// True if verified, false otherwise. bool VerifyPassword(string password, string salt, string passwordHash); /// /// Generate a cryptographically random string. /// /// Length of string to create. /// A random string. string GenerateRandomString(int length); }