Created
October 26, 2018 05:46
-
-
Save juancri/905873f2efc202466a4da1c47b4c68df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dependencies | |
const Enumerable = require ('linq'); | |
// Constants | |
const UPPER_CASE_CHARS = `ABCDEFGHIJKLMNOPQRSTUVWXYZ`; | |
const LOWER_CASE_CHARS = `abcdefghijklmnopqrstuvwxyz`; | |
const DIGITS = `0123456789`; | |
const SPECIAL_CHARS = `!@#$%^&*+=?/\\_`; | |
const VALID_CHARACTERS = | |
UPPER_CASE_CHARS + LOWER_CASE_CHARS + | |
DIGITS + SPECIAL_CHARS; | |
const LENGTH = 16; | |
// Generate | |
const pass = Enumerable | |
.range (0, LENGTH) | |
.select (() => Math.random () * VALID_CHARACTERS.length) | |
.select (r => Math.floor (r)) | |
.select (r => VALID_CHARACTERS [r]) | |
.toArray () | |
.join (''); | |
// Done | |
console.log (pass); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment