Skip to content

Instantly share code, notes, and snippets.

@skorotkiewicz
Created February 27, 2023 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skorotkiewicz/96926b1cde7ea293cc006c05bb7c333e to your computer and use it in GitHub Desktop.
Save skorotkiewicz/96926b1cde7ea293cc006c05bb7c333e to your computer and use it in GitHub Desktop.
JavaScript code to generate a unique password for each day
// Pobierz obecną datę
const now = new Date();
// Utwórz unikalny seed dla danego dnia
const seed = now.getFullYear() * 1000 + now.getMonth() * 100 + now.getDate();
// Zainicjuj generator liczb pseudolosowych z seedem
const m = 0x80000000;
let a = 1103515245;
let c = 12345;
let state = seed;
function random() {
state = (a * state + c) % m;
return state / m;
}
// Długość hasła
const passwordLength = 10;
// Znaki do wyboru
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
// Generuj losowe hasło
let password = "";
for (let i = 0; i < passwordLength; i++) {
password += characters.charAt(Math.floor(random() * characters.length));
}
// Wyświetl hasło w konsoli
console.log(password);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment