#!/usr/local/bin/perl
use strict;
sub get_input
{
my ($message) = @_;
local $| = 1;
local *TTY;
open TTY,"/dev/tty";
my ($tkey1, $tkey2);
system "stty -echo </dev/tty";
do {
print STDERR "Enter $message: "; chomp($tkey1 = <TTY>);
print STDERR "\nRe-type $message: "; chomp($tkey2 = <TTY>);
print STDERR "\n";
print STDERR "\nThe two $message", "s don't match. ",
"Please try again.\n\n" unless $tkey1 eq $tkey2;
} until $tkey1 eq $tkey2;
system "stty echo </dev/tty";
close TTY;
return $tkey1;
}
my $key = &get_input("username");
my $IV = pack "H32", "000102030405060708090a0b0c0d0e0f";
my $cipher = Crypt::CBC->new({'key' => $key,
'cipher' => 'Anubis',
'iv' => $IV,
'regenerate_key' => 1,
'padding' => 'standard',
'prepend_iv' => 0
});
my $ciphertext = $cipher->encrypt($key);
print "Your password is\n", encode_base64($ciphertext, ""), "\n";