GIT.Harvie.CZ
/
mirrors
/
Programs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improved goertzel documentation
[mirrors/Programs.git]
/
perl
/
rsa.pl
diff --git
a/perl/rsa.pl
b/perl/rsa.pl
index 522be22e1a79895d44acff37f5e8074e08e316a7..7c8b316392cd685556ce94fe6f3ee1d4d1315537 100755
(executable)
--- a/
perl/rsa.pl
+++ b/
perl/rsa.pl
@@
-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) = @_;
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)
}
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;
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";
print "=== TEST ===\nMSG: $msg\n";
my $enc=rsa($msg,$n,$e); #encrypt
print "ENC: $enc\n";
This page took
0.167731 seconds
and
4
git commands to generate.