On Wed, 03 Dec 2014 22:53:22 +0100
Alexander Hall wrote:

> >> If you want strong, short passwords that look ridiculous:
> >>
> >> dd if=/dev/random bs=1 count=9 | b64encode password
> >>  
> >
> >And then try to remember that mess, or type it, especially into
> >a smartphone. Gaak! 8-O  
> 
> base64 ain't that bad, but might lack those special symbols which we all know 
> makes all the difference between a bad and a good password...

This is what I came up with

#!/bin/sh
n="$1"
max=500
rn=$(($RANDOM %max + 1 ))
[[ -n "$n" ]] || n=12
if [[ $n -lt 8 ]]; then
        echo "Using 12 as the password length, a length of $n would be too weak"
fi
rn2=$rn
let rn2=$rn2+$n-1
p=$( /bin/dd if=/dev/urandom bs=2000 count=1 2>/dev/null | tr -cd 
"a-zA-Z0-9?.,!\"-()@/:_;+&%*=<>$[]{}/\~^#|" | cut -c "$rn"-"$rn2" )
echo "${p}"

Reply via email to