This commit is contained in:
Philippe Torrel
2026-09-30 15:00:47 +02:00
parent 8c7380fde9
commit 7a4748b549
32 changed files with 10536 additions and 0 deletions
@@ -0,0 +1,20 @@
// const crypto = require('node:crypto');
import crypto from 'node:crypto';
const PASSWORD_LENGTH = 10;
const s = '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ!.,;#$%/+*';
const buf = crypto.randomBytes(PASSWORD_LENGTH);
const password = Array.from(buf)
.map((byte) => s.charAt(byte % s.length))
.join('');
console.log(password);
// Übung 28: Passwortgenerator
// Was macht der folgende Code?
// OK: Der Titel verrät es schon. Versuche dennoch, das Programm zu verstehen! Benutze die Dokumentation der Standardbibliothek, um nachzuschlagen, was crypto.randomBytes(…) genau macht!
// Bonusfrage: Warum sind in den Zeichen «1», «i» und «l» nicht enthalten, genau so wenig wie «0» und «o»?