UNPKG

xypriss-security

Version:

Advanced High-Performance Security Framework. Military-grade encryption, post-quantum resilience, and fortified data structures.

54 lines 2.28 kB
"use strict"; /*************************************************************************** * XyPriss Security Core - Password Class ****************************************************************************/ Object.defineProperty(exports, "__esModule", { value: true }); exports.Password = void 0; const bridge_1 = require("./bridge"); /** * ### Password Class * * Secure password hashing and verification using industry-standard algorithms. */ class Password { /** * Hashes a password using a secure, memory-hard algorithm (Argon2id by default). * * @param password - The plain-text password to hash. * @param options - Configuration for the hashing algorithm (iterations, memory, parallelism). * @returns The final encoded password hash string. */ static async hash(password, options = {}) { const algo = (options.algorithm || "argon2id").toLowerCase(); const iterations = options.iterations || 0; const memory = options.memoryCost || 0; const parallelism = options.parallelism || 0; // Optional pepper support if provided in options const finalPassword = options.pepper ? password + options.pepper : password; return bridge_1.Bridge.hashPassword(finalPassword, algo, iterations, memory, parallelism); } /** * Verifies a plain-text password against a previously generated hash. * * @param password - The password to verify. * @param hash - The stored hash to compare against. * @param options - Optional configuration (e.g., pepper). * @returns True if the password matches the hash, otherwise false. */ static async verify(password, hash, options = {}) { const finalPassword = options.pepper ? password + options.pepper : password; return bridge_1.Bridge.verifyPassword(finalPassword, hash); } /** * Checks if a string is a valid XyPriss hash. * * @param hash - The string to check. * @param algorithm - Optional algorithm name to check against. * @returns True if it's a valid hash, otherwise false. */ static isHashed(hash, algorithm) { return bridge_1.Bridge.isHashed(hash, algorithm); } } exports.Password = Password; //# sourceMappingURL=Password.js.map