Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Created August 4, 2023 12:43
Show Gist options
  • Save apaleslimghost/6a363981d6391f9c4f53ff06fe0eafdf to your computer and use it in GitHub Desktop.
Save apaleslimghost/6a363981d6391f9c4f53ff06fe0eafdf to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const fs = require("fs");
const words = fs.readFileSync("/usr/share/dict/words", "utf-8").split("\n");
const mediumWords = words.filter((word) => word.length > 5 && word.length < 10);
const randomWord = (words) => words[Math.floor(words.length * Math.random())];
undefined;
const titleCase = (s) => s[0].toUpperCase() + s.slice(1).toLowerCase();
undefined;
const getPassword = (words) =>
Array.from({ length: 3 }, () => titleCase(randomWord(words)))
.join("-")
.replace(/[aio]/, (m) => ({ a: 4, i: 1, o: 0 })[m]);
console.log(getPassword(mediumWords));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment