Home >Web Front-end >JS Tutorial >Stateless Password Generator: Secure and Hassle-Free Password Management
Managing multiple passwords across various platforms can be daunting. The Stateless Password Generator simplifies this process using a secure, stateless Master Password algorithm. This tool eliminates the need to store passwords while ensuring robust security. It’s available for installation on the Chrome Web Store, operating entirely offline for maximum privacy.
E.g: Generate passwords for Facebook
The Stateless Password Generator employs a cryptographic hash function to generate unique passwords for each website. The algorithm ensures the generated passwords adhere to the user-defined constraints, such as required character types and maximum length.
Here’s a breakdown of the password generation process:
Hashing: The inputs are combined into a single string and hashed using the SHA-256 algorithm. This ensures a unique and deterministic hash value for each set of inputs.
Password Construction:
Below are key functions that power the Stateless Password Generator:
const upperChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; const lowerChars = 'abcdefghijklmnopqrstuvwxyz'; const numberChars = '0123456789'; const specialChars = '!@#$%^&*()'; const CHARACTER_SETS = { uppercase: upperChars, lowercase: lowerChars, number: numberChars, special: specialChars, };
async function hashPassword(userData) { const combinedString = userData.domain + userData.username + userData.masterPassword + userData.pwVersion; const encoder = new TextEncoder(); const passwordHash = await crypto.subtle.digest('SHA-256', encoder.encode(combinedString)); const passwordHashArray = Array.from(new Uint8Array(passwordHash)); const allRequiredChars = getRequireChars(getRequireRules( userData.isRequiredUpperCase, userData.isRequiredLowerCase, userData.isRequiredNumber, userData.isRequiredSpecial )); let password = ""; for (let i = 0; i < userData.maxLength; i++) { let byte = passwordHashArray[i % passwordHashArray.length]; password += allRequiredChars[byte % allRequiredChars.length]; } return password; }
function getRequireRules(isRequiredUpperCase, isRequiredLowerCase, isRequiredNumber, isRequiredSpecial) { let rules = []; if (isRequiredUpperCase) rules.push('uppercase'); if (isRequiredLowerCase) rules.push('lowercase'); if (isRequiredNumber) rules.push('number'); if (isRequiredSpecial) rules.push('special'); return rules; }
The Stateless Password Generator is a powerful tool for managing passwords securely and efficiently. By leveraging cryptographic hashing and stateless algorithms, it offers robust protection without compromising usability. Install it from the Chrome Web Store!
Please checkout the GitHub for more details.
Enjoying the project? Don’t forget to star it ⭐!
The above is the detailed content of Stateless Password Generator: Secure and Hassle-Free Password Management. For more information, please follow other related articles on the PHP Chinese website!