Roland's homepage

My random knot in the Web

Generate random passwords

One way of making hard to guess passwords is to take random data and encode it with base64 to make it readable. This is what I’ve done in the genpw.py script.

This is mainly useful for passwords that you can store in a secure manner (like in an encrypted file) and copy/paste whenever you need them.

It uses the random(4) device by default because that is the non-blocking random device on FreeBSD. On Linux you might want to change that to /dev/urandom.

It has been ported to python 3, and the default password length has been increased from 8 to 16 characters.

Some examples of how to use it are shown below.

> genpw -h
usage: genpw [-h] [-l LENGTH] [-r REPEAT] [-d DEVICE] [-v]

Generate random passwords.

optional arguments:
-h, --help            show this help message and exit
-l LENGTH, --length LENGTH
                        # of random character for password (default 16)
-r REPEAT, --repeat REPEAT
                        number of passwords to generate (default: 1)
-d DEVICE, --device DEVICE
                        random number device (default: /dev/random)
-v, --version         show program's version number and exit

> genpw -r 5
s7s7lmr63EHNhUxQ
roVtAghqlTSZVzoY
PvRXPdhGgnmVVV84
lbiX9ID_NUKBYZre
yfsDzgY_vj9pxejH
> genpw -r 5 -l 32
zccMOjNkgnnYAGS2_KzH3LWExfsFkqiK
6O4OY6IWtybHGBeAgt6fcH8cPuw8GfOT
IsCvfzzrmhsVjtqz_YAODvGjfovuXKWT
COrtClfbpRNkZ8CY8cIushW0U9ABpI0C
i19BvQARd2phLrOGVuqh37etk_QvBG71

The genpw.py script can be downloaded from github.

Note

creative commons public domain logo

To the extent possible under law, Roland Smith has waived all copyright and related or neighboring rights to genpw.py. This work is published from the Netherlands.


←  vid2mkv Stltools  →