Created
November 12, 2014 17:13
-
-
Save natmchugh/db8e0864935b9e5d6fbc to your computer and use it in GitHub Desktop.
Decode RSA 129 http://en.wikipedia.org/wiki/RSA_numbers#RSA-129
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$p = '3490529510847650949147849619903898133417764638493387843990820577'; | |
$q = '32769132993266709549961988190834461413177642967992942539798288533'; | |
$N = bi_mul($p, $q); | |
$c ='96869613754622061477140922254355882905759991124574319874695120930816298225145708356931476622883989628013391990551829945157815154'; | |
$phin = bi_mul(bi_sub($p, 1), bi_sub($q, 1)); | |
$e = 9007; | |
$d = bi_invmod($e, $phin); | |
$m = bi_powmod($c, $d, $N); | |
$m = bi_to_str($m, 10); | |
$m = str_split($m, 2); | |
$letters = range('A', 'Z'); | |
array_unshift($letters, ' '); | |
foreach ($m as $int) { | |
echo $letters[(int) $int]; | |
} | |
echo PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment