Create strong passwords

At a recent #ubuntu-us-az meeting, this url was posted as an easy way to generate a password. I kinda liked option 4 which uses perl, available in most Linux distros. Should you not have it, apt-get install perl will install it.

#!/usr/bin/perl
#
# REF https://www.ostechnix.com/4-easy-ways-to-generate-a-strong-password-in-l...
# save as pw.pl
#
my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);
my $randpassword = join '', map $alphanumeric[rand @alphanumeric], 0..7;
print "$randpassword\n"

The code is simple, it creates an array with all the upper, lowercase, and numeric characters. You could add special characters into that array if you want. The [rand @array] generates a random number between 0 and the length of the array, the map $array maps the random number to the random-th element of the array, the join function will join those characters together and it will repeat this 8 times, 0..7

Executing perl pw.pl a few times will help the randomless of the generated password.

--

Tags: