miércoles, 20 de enero de 2010

Generar Password script

#!/bin/bash
n="$1"
[[ -n "$n" ]] || n=12
if [[ $n -lt 8 ]]; then
echo "A password of length $n would be too weak"
exit 1
fi
p=$( dd if=/dev/urandom bs=512 count=1 2>/dev/null \
| tr -cd 'a-zA-Z0-9' \
| cut -c 1-$n )
echo "${p}"

No hay comentarios: