Random Password Generator in Javascript

I’ve been wanting to have a simple password generator. There are a few solutions out on the internet, but none quite what I wanted. Here is a simple and customizable JavaScript password generator.

First I had to figure out what characters I would want in my password generator. There are the basic four, lowercase letters, uppercase letters, numbers, and symbols.

In this example, I have implemented those four. For the symbols, I went with “safe symbols”, which are the symbols that do not need to be escaped in most programming language’s strings. They are ~!@#%*-_=+.,:;.

The form HTML is simple. I am using bootstrap for this.

The .form-check-input is an important class that I am binding to.

Here’s the JavaScript.

What is going on here?

We have our pool variable, which holds the pool of characters we can pick from. It comes from the text in the #txtPool textbox, which can be filled by hand. Checking the different checkboxes will populate #txtPool with what is in their data-pool attribute. Using the transpiler (line 2) enables support for multi-byte characters like emoji.

I have a demo of that at rndpwd.lupecode.com, feel free to use it to make any password you need. As it runs in your browser it does not impact my server.