4 ## Written by Owen Taylor <otaylor@redhat.com>
10 use POSIX
qw(:termios_h);
12 my ($term, $oterm, $echo, $noecho, $fd_stdin);
14 $fd_stdin = fileno(STDIN
);
16 $term = POSIX
::Termios
->new();
17 $term->getattr($fd_stdin);
18 $oterm = $term->getlflag();
20 $echo = ECHO
| ECHOK
| ICANON
;
21 $noecho = $oterm & ~$echo;
24 $term->setlflag($noecho);
25 $term->setattr($fd_stdin, TCSANOW
);
29 $term->setlflag($oterm);
30 $term->setattr($fd_stdin, TCSANOW
);
38 open(RANDOM
, "/dev/random") || die "Can't open /dev/random: $!";
39 read(RANDOM
, $a, 8) || die "Can't read: $!";
42 $a = join ("", map { chr(ord('0') + ord($_)%64) } split //,$a);
43 $a =~ s/[^A-Za-z0-9]//g;
45 my ($result1, $result2);
50 print "Enter passwd: ";
54 $result1 = crypt($password, substr($a,0,2));
56 print "\nReenter passwd to verify: ";
60 $result2 = crypt($password, substr($a,0,2));
63 if ($result1 ne $result2) {
64 print "\nPasswords did not match, try again\n";
70 print "\nCrypted value is: $result1\n";