Created
October 16, 2022 15:29
-
-
Save th3terrorist/230fb35cb5a0c6273107659d0773ddd0 to your computer and use it in GitHub Desktop.
Very safe password gen
This file contains hidden or 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
import crypto from "crypto"; | |
let randGenData = { | |
index: 0, | |
bytes: [], | |
poolSize: 512 | |
}; | |
// Generates a word by [' ', ~) from https://www.asciitable.com/ | |
const genRandPass = (length) => { | |
const genRandValue = () => { | |
if (randGenData.index >= randGenData.bytes.length) { | |
randGenData.index = 0; | |
randGenData.bytes = crypto.randomBytes(randGenData.poolSize); | |
} | |
return randGenData.bytes[randGenData.index++]; | |
} | |
let pass = ""; | |
for (let _ = 0; _ < length; ++_) { | |
let randvalue = genRandValue() % 94; | |
pass += String.fromCharCode(33 + randvalue); | |
} | |
return pass; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment