Skip to content

Instantly share code, notes, and snippets.

@jakeydevs
Created July 15, 2015 08:58
Show Gist options
  • Save jakeydevs/c9e34d067a22b6fdce93 to your computer and use it in GitHub Desktop.
Save jakeydevs/c9e34d067a22b6fdce93 to your computer and use it in GitHub Desktop.
Javascript Pretty Passwords
//-- prettyPassword.js
window.prettyPassword = {
//-- Password Vars
pass: "",
sep: "",
//-- generate
generate: function() {
var _this = this;
//-- Run the system
this.pass = "";
this.pass = this.pass + this.adjective() + this.sep + this.noun() + this.sep + this.number();
//-- return value
return this.pass;
},
//-- pick Adjective
adjective: function() {
//-- List of Adjectives (63)
var db = ["adorable", "beautiful", "clean", "drab", "elegant", "fancy", "glamorous", "handsome", "long", "magnificent", "plain", "quaint", "sparkling", "ugliest", "unsightly", "red", "orange", "yellow", "green", "blue", "purple", "gray", "black", "white", "alive", "better", "careful", "clever", "dead", "easy", "famous", "gifted", "helpful", "important", "inexpensive", "mushy", "odd", "powerful", "rich", "shy", "tender", "vast", "wrong", "angry", "bewildered", "clumsy", "defeated", "embarrassed", "fierce", "grumpy", "helpless", "itchy", "jealous", "lazy", "mysterious", "nervous", "obnoxious", "panicky", "repulsive", "scary", "thoughtless", "uptight", "worried"];
//-- Get Random
return db[Math.floor(Math.random() * db.length)];
},
//-- pick Noun
noun: function() {
//-- List of Nouns (100)
var db = ["muscle", "verse", "mark", "pizzas", "pet", "kiss", "zephyr", "teeth", "shade", "back", "toothpaste", "achiever", "liquid", "observation", "decision", "current", "lunch", "appliance", "skate", "store", "sky", "wax", "cakes", "jewel", "sticks", "celery", "lace", "reason", "circle", "trucks", "tongue", "mailbox", "frame", "camp", "pull", "ring", "summer", "authority", "watch", "icicle", "railway", "debt", "run", "territory", "window", "smell", "teaching", "yarn", "offer", "cheese", "beef", "credit", "string", "wrist", "rule", "cap", "jar", "church", "car", "monkey", "route", "angle", "place", "hill", "mass", "bed", "cough", "waves", "lock", "van", "sail", "flowers", "friend", "tomatoes", "distance", "bear", "low", "food", "hat", "side", "form", "value", "fish", "air", "act", "coil", "grade", "action", "brass", "sugar", "dog", "truck", "harbor", "quilt", "button", "instrument", "mom", "wall", "smoke", "sister", "pigs", "crib", "cup", "sort", "road", "position", "use", "flag", "bells", "hammer", "letter", "smash", "son", "head", "stamp", "plant", "plane", "waste", "gun", "ice", "yam", "wool", "shirt", "school", "things", "ship", "drain", "island", "size", "library", "step", "pancake", "tent", "ghost", "plants", "tendency", "fairies", "stocking", "digestion", "coach", "chance", "bulb", "fireman", "sound", "building", "finger", "join", "dogs", "baby", "pipe"];
//-- Get Random
return db[Math.floor(Math.random() * db.length)];
},
//-- pick Random 2 digit number
number: function() {
var n = Math.floor(Math.random() * 99);
return this.pad(n, 2);
},
//-- Padding function
//-- http://stackoverflow.com/questions/10073699/pad-a-number-with-leading-zeros-in-javascript
pad: function(n, width, z) {
//-- Pad N with Z until WIDTH length
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
}
@jakeydevs
Copy link
Author

Really simple function to generate a pretty password (readable password). Use by prettyPassword.generate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment