Random string generator


A random string generator is useful to generate passwords and codes with better randomness than a simple guess.

Typical password entry dialog box

It's quite difficult to invent a random code or string: this utility may help. Generating a random code is not an easy task for a computer that can only execute sequential ant totally reproducible code. To generate random numbers, pseudo-random generators are used: if correctly designed, they produce numbers with a good probability distribution (every number generated is equally probable), but they are highly predictable since the generated numbers are not random but are part of a long and well defined sequence.

To make sure the generated codes cannot be predicted, some real randomness should be included. In this calculator, we use the mouse-clicks one makes on the rectangle below to increase the randomness. Of course, if one could access or see the screen when the clicks take place, it would have some more clues to guess the code, but let's assume that the operation of clicking is done in a good privacy. It should also be stressed that this script is executed locally in the browser and that there is no communication on the network. Since the code displayed is not sent over the network, it cannot be easily sniffed by a third party.

So, this calculator works in two steps: first you click in the rectangle enough times to collect random data, than you select the format you need and hit the "calculate" button. The algorithm is designed in such a way that every mouse-click generates the required randomness to generate two characters.

Step 1: collect random data

The first step is to collect enough random data. Just click in the rectangle below as randomly as possible: every mouse-click will generate a word of 16 bits of random data: 4 bits are taken from the of the mouse horizontal position, 4 bits are taken from the mouse vertical position and 8 bits from the timestamp in millisecond. Of course, only the least significant bits are used because they are the least predictable.

Random click area: click here as randomly as possible
Collected random words: 0

All random words are stored in memory. Beware, if you refresh the page in the browser, they will be lost. When you have enough random data go to the next step and generate the code.

Step 2: generate random code

When you have enough random data, it's time to generate the random string. Just select the options you like and hit the "calculate" button. You can combine different character sets: they are not all compatible and the selection changes accordingly. You cannot deselect all character sets.

Character set:
Binary (0, 1)
Hexadecimal (0..F)
Lower case letters (a..z)
Upper case letters (A..Z)
Numbers (0..9)
ASCII symbols (+"*...)
Space (" ")
String format:
String length: random characters
Group every characters
Group prefix
Group suffix
Group separator
Random string:
Automatic setup:

Every symbol has the same probability: this means that even if you select two different character sets, you may get a code with only characters of one of them. If you need at least some characters of every set, just repeat the procedure until a suitable code is obtained. Please keep in mind that you need a random word for every two characters you generate.