Kleiner Passwort-Generator

Hier geht es zum Generator > Klick mich

Console
var http = require('http');
var ip = require('ip');
var readline = require('readline');

var randomString = (function() {
  var uppers = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  var lowers = 'abcdefghijklmnopqrstuvwxyz';
  var numbers = '0123456789';
  var specials = '_-|@.,?/!~#$%^&*(){}[]+=';
  var charClasses = [uppers, lowers, numbers, specials];
  var minLen = charClasses.length;
  function chooseRandom(x) {
    var i = Math.floor(Math.random() * x.length);
    return (typeof(x)==='string') ? x.substr(i,1) : x[i];
  }
  return function(maxLen) {
    maxLen = (maxLen || 36);
    if (maxLen < minLen) { throw new Error('length must be >= ' + minLen); }
    do {
      var str='', usedClasses={}, charClass;
      while (str.length < maxLen) {
        charClass = chooseRandom(charClasses);
        usedClasses[charClass] = true;
        str += chooseRandom(charClass);
      }
    } while (Object.keys(usedClasses).length !== charClasses.length);
    return str;
  }
})();
randomString();
randomString();
randomString();
randomString();
randomString();
randomString();

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
rl.question("Wie viele Passwoerter sollen generiert werden? ", function(answer) {
  http.createServer(function (req, res)
  {
    res.writeHead(200, {'Content-type': 'text/plain'});
    for(var i = 0; i < answer;i++){
      res.write(randomString(20)+'\n');
    }
    res.write("\nDruecke F5, um neue Passwoerter zu erhalten.");
    res.end();
  }).listen(8357);
  console.log('Erfolg! Die Passwoerter stehen zur Verfuegung unter https://randompass.lynxden.de');
  rl.close();
});