View Single Post
Old 24th February 2014
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

Just for fun, I wrote a little shell script that generates pseudo-random passwords along the lines hinted at above. The features are:

* Uses /dev/random by default, or /dev/urandom with the -u flag.

* Passwords can be from 1 to 63 characters long.

* The characters come from a set of 64 ASCII characters, uniformly distributed (assuming output from /dev/[u]random is so).

* The use of entropy is quite efficient in that every 3 bytes read from /dev/[u]random can generate 4 characters. This is done by saving unused bits and reassembling them.

Code:
$ randpw.sh
Usage> randpw.sh [-u] LENGTH
        LENGTH : Length of password (1,...,63)
          -u   : Use /dev/urandom (default: /dev/random)
Code:
$ randpw.sh -u 10
%_9EL^;PO[
It seems to work on sh, ksh, bash. Suggestions, etc., welcome.

randpw.sh.gz
Reply With Quote