Po lewej jest prosty generator haseł. Żadne dane nie są zapisywane nigdzie. Działa on lokalnie na Twojej przeglądarce.
Poniżej zawarty jest kod źródłowy skryptu.
<!DOCTYPE html>
<html>
<body>
<font color=white>
<label>Długość hasła (4-64 znaki):
<input type="number" id="length" value="12" min="4" max="64">
</label><br><br>
<label><input type="checkbox" id="uppercase"> Użyj dużych liter</label><br>
<label><input type="checkbox" id="numbers"> Użyj cyfr</label><br>
<label><input type="checkbox" id="special"> Użyj znaków specjalnych</label><br><br>
<button onclick="generate()">Generuj hasło</button><br><br>
<input type="text" id="result" readonly style="width: 300px;"><br><br>
<script>
function generatePassword(length, options = {}) {
const lowercase = 'abcdefghijklmnopqrstuvwxyz';
const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const digits = '0123456789';
const special = '!@#$%^&*()-_=+[]{}|;:,.<>?/`~';
let charset = '';
if (options.includeLowercase !== false) charset += lowercase;
if (options.includeUppercase) charset += uppercase;
if (options.includeNumbers) charset += digits;
if (options.includeSpecialChars) charset += special;
if (charset.length === 0) {
return 'Select at least one character type!';
}
let password = '';
for (let i = 0; i < length; i++) {
password += charset[Math.floor(Math.random() * charset.length)];
}
return password;
}
function generate() {
const length = parseInt(document.getElementById('length').value);
const options = {
includeUppercase: document.getElementById('uppercase').checked,
includeNumbers: document.getElementById('numbers').checked,
includeSpecialChars: document.getElementById('special').checked,
};
const password = generatePassword(length, options);
document.getElementById('result').value = password;
}
</script>
</font>
</body>
</html>