From: Harvie Date: Thu, 4 Nov 2010 22:34:55 +0000 (+0100) Subject: Added testing mechanism to RSA.pl X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=ecdf2356b7be385b56c237a07738ce1b895d2756;p=mirrors%2FPrograms.git Added testing mechanism to RSA.pl --- diff --git a/perl/rsa.pl b/perl/rsa.pl index c442c6e..522be22 100755 --- a/perl/rsa.pl +++ b/perl/rsa.pl @@ -44,4 +44,6 @@ my $msg=1337; my $enc=rsa($msg,$n,$e); #encrypt print "ENC: $enc\n"; my $dec=rsa($enc,$n,$d); #decrypt - print "DEC: $dec\nTST: ".$msg.($msg==$dec?"=":"!=").$dec."\n"; + $test=($msg==$dec); + print "DEC: $dec\nTST: ".$msg.($test?"=":"!=").$dec."\n"; + exit !$test;