TODO: Reimplement RSA.pl using chinese remainder theorem (too slow right now)
authorHarvie <tomas@mudrunka.cz>
Sun, 7 Nov 2010 23:01:39 +0000 (00:01 +0100)
committerHarvie <tomas@mudrunka.cz>
Sun, 7 Nov 2010 23:01:39 +0000 (00:01 +0100)
perl/rsa.pl

index 522be22e1a79895d44acff37f5e8074e08e316a7..7c8b316392cd685556ce94fe6f3ee1d4d1315537 100755 (executable)
@@ -5,7 +5,7 @@ use bignum; #We'll need bignum for real messages
 
 sub rsa { #RSA (de)crypt function (message,modulus,exponent)
        my ($msg,$m,$e) = @_;
-       ($msg**$e)%($m);
+       ($msg**$e)%($m); #TODO: reimplement using chinese remainder theorem (this is too slow!!!)
 }
 
 sub isprime { #Tell if number is prime or not (suboptimal)
@@ -40,6 +40,7 @@ print "\t[[[ Harvie's simple RSA demo ]]]\nfor study & testing purposes only (IN
 print "=== KEYS ===\nPUB: ($n,$e)\nPRV: ($n,$d)\n";
 
 my $msg=1337;
+$msg=$n-1;
        print "=== TEST ===\nMSG: $msg\n";
 my $enc=rsa($msg,$n,$e); #encrypt
        print "ENC: $enc\n";
This page took 0.124427 seconds and 4 git commands to generate.