#!/usr/bin/perl # допустимые символы в пароле $passstr = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+|=-;:"; # сгенерируем srand(time()+$$); $t = ""; for (1..10) { $c = int(rand(length($passstr))); $t = $t . substr($passstr,$c,1); } $PASS=$t; if ($#ARGV == 0) { $PASS=$ARGV[0]; } # зашифруем его $cryptpwd = crypt($PASS, &salt); print "$PASS\t$cryptpwd\n"; sub salt { local($salt); # initialization local($i, $rand); local(@itoa64) = ( 0 .. 9, a .. z, A .. Z ); # 0 .. 63 warn "calculate salt\n" if $verbose > 1; # to64 for ($i = 0; $i < 8; $i++) { srand(time + $rand + $$); $rand = rand(25*29*17 + $rand); $salt .= $itoa64[$rand & $#itoa64]; } warn "Salt is: $salt\n" if $verbose > 1; $salt="\$1\$$salt\$"; # print "salt is = $salt\n"; return $salt; }
Результат работы:
$ pass_gen 02:3sp|&)3 $1$oph4oJMs$Pvvs0lauhj1QY7pohXdEM/ $ pass_gen P0jio8I6JK $1$JxxZFYM0$rqEvFlXrLuyDpG/npkOtx. $ pass_gen +Cd=tBUkrr $1$NhZtFtt1$d33kzNPz48NChzXTV0umi0 $ pass_gen UIp@wDY4KH $1$gshtpl1J$sSup5tjy7mgpB3a1q1d470 $ pass_gen 'supersecretparol:)' supersecretparol:) $1$9wQgc55U$DL64u6yHDvfqC8eV3kARU/