[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RES: [shell-script] Gerar passwords pronunciaveis
From: |
Viktor Mota |
Subject: |
Re: RES: [shell-script] Gerar passwords pronunciaveis |
Date: |
Fri, 14 May 2004 14:03:31 -0300 |
Olá Pedro Henrique Ponchio,
quinta-feira, 13 de maio de 2004, 19:29:33, você escreveu:
Muito boa as funcoes do mestre yoda!
Achei esse procurando na net, estou enviando mais para ficar no
historico da lista.
==========================================================================================
#!/bin/bash
# May need to be invoked with #!/bin/bash2 on older machines.
#
# Random password generator for Bash 2.x by Antek Sawicki <address@hidden>,
# who generously gave permission to the document author to use it here.
#
# ==> Comments added by document author ==>
MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
# ==> Password will consist of alphanumeric characters.
LENGTH="8"
# ==> May change 'LENGTH' for longer password.
while [ "${n:=1}" -le "$LENGTH" ]
# ==> Recall that := is "default substitution" operator.
# ==> So, if 'n' has not been initialized, set it to 1.
do
PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
# ==> Very clever, but tricky.
# ==> Starting from the innermost nesting...
# ==> ${#MATRIX} returns length of array MATRIX.
# ==> $RANDOM%${#MATRIX} returns random number between 1
# ==> and [length of MATRIX] - 1.
# ==> ${MATRIX:$(($RANDOM%${#MATRIX})):1}
# ==> returns expansion of MATRIX at random position, by length 1.
# ==> See {var:pos:len} parameter substitution in Chapter 9.
# ==> and the associated examples.
# ==> PASS=... simply pastes this result onto previous PASS
(concatenation).
# ==> To visualize this more clearly, uncomment the following line
# echo "$PASS"
# ==> to see PASS being built up,
# ==> one character at a time, each iteration of the loop.
let n+=1
# ==> Increment 'n' for next pass.
done
echo "$PASS" # ==> Or, redirect to a file, as desired.
exit 0
==========================================================================================
PHP> Olá,
PHP> Com relação à senha randômica tem o zzsenha do Aurélio, que
PHP> é mais ou menos o que tá abaixo:
PHP> gera_senha () {
PHP> alpha="abcdefghijklmnopqrstuvwxyz0123456789" #politica de senhas
PHP> n="7" #numero de caracteres
PHP> [ "$1" ] && n=`echo "$1" | sed 's/[^0-9]//g'`
PHP> [ $n -gt 37 ] && {
PHP> echo "O tamanho máximo da senha é 37" && $FALHOU && $STATUS && exit
PHP> return
PHP> };
PHP> while [ $n -ne 0 ]; do
PHP> n=$((n-1))
PHP> pos=$((RANDOM%${#alpha}+1))
PHP> echo -n "$alpha" | sed "s/\(.\)\{$pos\}.*/\1/"
PHP> alpha=`echo $alpha | sed "s/.//$pos"`
PHP> done | tr -d '\012'
PHP> }
PHP> Dentro da variavel "alpha" voce escolhe as letras e numeros
PHP> que "participam" da geração aleatória (neste caso, somente as
PHP> [a-z] :-)
PHP> Acho que para gerar passwords pronunciáveis voce tem que
PHP> gerar sempre um "alpha" (somente consoantes) em conjunto com um
PHP> "alpha" (somente vogais).
PHP> []Žs
PHP> Pedro
PHP> -----Mensagem original-----
PHP> De: Viktor Mota [mailto:address@hidden]
PHP> Enviada em: quinta-feira, 13 de maio de 2004 18:14
PHP> Para: address@hidden
PHP> Assunto: [shell-script] Gerar passwords pronunciaveis
PHP> Olá ,
PHP> Preciso de um script para gerar passwords pronunciaveis, achei muita
PHP> coisa boa na internet, porem nada em sh.
PHP> http://www.blueroo.net/max/pwdgen.php
PHP> Alguem pode dar um help de um shell scrip, baseando-se na formula da
PHP> pagina acima?
PHP> Ainda aproveitando o encejo, alguem tem algum sh que gere senhas,
PHP> mesmo que aleatorias?
PHP> []s
PHP> Viktor Mota
PHP> address@hidden
PHP> --- tagline ---
PHP> O cúmulo... Da vaidade 1: Enfeitar os vasos sangüíneos com flores
[]s
Viktor Mota
address@hidden
--- tagline ---
Windows: faz tudo que o DOS faz e ainda te dá tempo de ler o jornal.