Below is the JavaScript code which generates the random characters above. The script takes user input
to determine how long the expression is [default=12] It is hosted locally [on this very page] and makes no
references to API's or Google and Amazon servers, etc. The JavaScript code snippet is open for you to copy and
modify. For example, you could modify or restrict which characters are sourced from the "var char" string.
function randomString() {
const password = document.getElementById('password').value;
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz~!@#$%^&*()_+{}:?><;.,";
var string_length = password;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
}
document.randform.randomfield.value = randomstring;
}
onload = randomString();