old-silvrgit/lib/password.js
Martin Donnelly 9fcfc7ac05 updates
2016-02-11 14:48:05 +00:00

69 lines
2.4 KiB
JavaScript

var http = require('http');
Array.prototype.random = function () {
return this[Math.floor((Math.random() * this.length))];
};
var alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
var whitespace = ['.', '~', '#', '!', '$', '+', '-', '+'];
var numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
var left = ["Alabama",
"Alaska",
"Arizona",
"Maryland",
"Nevada",
"Mexico",
"Texas",
"Utah",
"Glasgow",
"Inverness",
"Edinburgh",
"Dumbarton",
"Balloch",
"Renton",
"Cardross",
"Dundee",
"Paisley",
"Hamilton",
"Greenock",
"Falkirk",
"Irvine",
"Renfrew",
"Erskine",
"London",
"Hammersmith",
"Islington",
"Silver", "Black", "Yellow", "Purple", 'White', 'Pink', 'Red', 'Orange','Brown','Green','Blue','Amber','Aqua','Azure','Bronze','Coral','Copper','Crimson','Cyan','Ginger','Gold','Indigo','Jade'
];
var right = ['Aganju', 'Cygni', 'Akeron', 'Antares', 'Aragoth', 'Ardus', 'Carpenter', 'Cooper', 'Dahin', 'Capella', 'Endriago', 'Gallina', 'Fenris', 'Freya', 'Glenn', 'Grissom', 'Jotunheim', 'Kailaasa', 'Lagarto', 'Muspelheim', 'Nifleheim', 'Primus', 'Vega', 'Ragnarok', 'Shepard', 'Slayton', 'Tarsis', 'Mercury', 'Venus', 'Mars', 'Earth', 'Terra', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto', 'Europa', 'Ganymede', 'Callisto', 'Titan', 'Juno', 'Eridanus', 'Scorpius', 'Crux', 'Cancer', 'Taurus', 'Lyra', 'Andromeda', 'Virgo', 'Aquarius', 'Cygnus', 'Corvus', 'Taurus', 'Draco', 'Perseus', 'Pegasus', 'Gemini', 'Columbia', 'Bootes', 'Orion', 'Deneb', 'Merope'];
var numberCluster = function () {
return numbers.random() + numbers.random() + numbers.random();
};
var randomAmount = function (i) {
var str = '';
for (var t = 0; t < i; t++) {
str = str + alpha.random();
}
return str;
};
module.exports = {
generate: function (req, res) {
var reply = {
long: (left.random() + ' ' + right.random() + ' ' + numberCluster() + ' ' + numberCluster()).split(' ').join(whitespace.random()),
short: randomAmount(10)
};
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(reply));
}
};