[Refdb-cvs] CVS: perlmod/RefDBClient test.pl,1.7,1.8
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2005-01-22 01:12:18
|
Update of /cvsroot/refdb/perlmod/RefDBClient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20529 Modified Files: test.pl Log Message: added password encryption test Index: test.pl =================================================================== RCS file: /cvsroot/refdb/perlmod/RefDBClient/test.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -U2 -r1.7 -r1.8 --- test.pl 17 Feb 2004 22:45:41 -0000 1.7 +++ test.pl 22 Jan 2005 01:12:08 -0000 1.8 @@ -62,5 +62,57 @@ my $numtest = 1; my $numok = 1; -my $numtotal =25; +my $numtotal =26; + +# password encryption test +print "$numtest..$numtotal: "; +$numtest++; + +my $enigma = new RefDBClient::Enigma; + +my $scramble; +my $randno = abs(rand() * 6); + +if ($randno < 1) { + $scramble = "012"; +} +elsif ($randno < 2) { + $scramble = "021"; +} +elsif ($randno < 3) { + $scramble = "120"; +} +elsif ($randno < 4) { + $scramble = "102"; +} +elsif ($randno < 5) { + $scramble = "201"; +} +else { + $scramble = "210"; +} + +for my $i (0 .. 2) { + $randno = abs(rand() * 93); + $scramble .= sprintf("-%02d", $randno); +} +$enigma->init("heinzmeier", $scramble); + +$enigma->eenc(); + +my $renigma = new RefDBClient::Enigma; + +$renigma->init($enigma->{encodedpass}, $scramble); + +$renigma->eenc(); + +if ($enigma->{rawpass} eq $renigma->{encodedpass}) { + print "password encryption ok:$renigma->{encodedpass}\n"; +} +else { + print "password encryption broken\n"; + exit 1; +} + +#exit 0; # we need two clients for the refdba and refdbc functions as the |