+ brackets; let secret = ""; for (let index = 0; index < length; index++) secret += all.charAt(randomInt(all.length)); return secret; }; Perl This example uses the Crypt::Random::Source module to find a source of strong random numbers (which is platform dependent). use Crypt::Random::Source qw(get_strong); while(length($out) < 15) { my $a = get_strong(1); $a =~ s/[^[:graph:]]//g; $out .= $a; } print $out; Python The language Python includes a SystemRandom class that obtains cryptographic grade random bits from /dev/urandom on a Unix-like system, including Linux and macOS, while on Windows it uses CryptGenRandom. Here is a simple Python script that demonstrates the use of this class: #!/usr/bin/env python3 import random, string myrg = random.SystemRandom() length = 10 alphabet = string.ascii_letters + string.digits # a-z A-Z 0-9 password = "".join(myrg.choice(alphabet) for _ in range(length)) print(password) PHP A PHP program can open and read from /dev/urandom, if available, or invoke the Microsoft utilities. A third option, if OpenSSL is available is to employ the function openssl_random_pseudo_bytes'.''' Mechanical methods Yet another method is to use physical devices such as dice to generate the randomness. One simple way to do this uses a 6 by 6 table of characters. The first die roll selects a row in the table and the second a column. So, for example, a roll of 2 followed by a roll of 4 would select the letter "j" from the fractionation table below. To generate upper/lower case characters or some symbols a coin flip can be used, heads capital, tails lower case. If a digit was selected in the dice rolls, a heads coin flip might select the symbol above it on a standard keyboard, such as the '$' above the '4' instead of '4'. {| class="wikitable" ! |1||2||3||4||5||6|- |1! a ! b ! c ! d ! e ! f |- |2! g ! h ! i ! j ! k ! l |- |3! m ! n ! o ! p ! q ! r |- |4! s ! t ! u ! v ! w ! x |- |5! y ! z ! 0 ! 1 ! 2 ! 3 |- |6! 4 ! 5 ! 6 ! 7 ! 8 ! 9 |} Type and strength of password generated Random password generators normally output a string of symbols of specified length. These can be individual characters from some character set, syllables designed to form pronounceable passwords, or words from