[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: gestion d'un serveur FTP - création des users



Le sam 12/10/2002 à 14:40, arnaud a écrit :
> Bonjour,
> 
> voici un petit programme perl pour generer des mots de passe, 
> l'inconvenient sont qu'ils ne sont pas evident a retenir et la tentation 
> de les noter sur un bout de papier trop grande.
> 
> #!/usr/bin/perl -w
> #password_generator.pl
> use strict;
> my @chars=(33..91,93..126);
> my $num_chars = @chars;
> my $length;
> my $funny = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
> print "Entrer le nombre de caracteres de votre mot de passe : ";
> chomp($length = <STDIN>);
> die "La longueur doit etre superieur a 8 caracteres !" if $length <=7;
> 
> while (1) {
>          my $password = '';
>          foreach (1...$length) {
>                  $password .= chr($chars[int(rand($num_chars))]);
>          }
>          if ($password =~ /[a-z]/ and $password =~ /[A-Z]/ and $password 
> =~/[0-9]
> / and $password =~ /[$funny]/){
>                  print $password, "\n";
>                  exit;
>          }
> }


En une ligne

perl -we "use strict; my @a = (); push @a, ('.', '/', 0..9,'A'..'Z',
'a'..'z')[rand 64] for (1 .. 10); print join('', @a), \"\n\""

Sinon, dans les packages Debian, il existe

gpw - Trigraph Password Generator
makepasswd - Generate and encrypt passwords
pwgen - Automatic Password generation




Reply to: