Skip to content

Instantly share code, notes, and snippets.

@natmchugh
Created November 12, 2014 17:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natmchugh/db8e0864935b9e5d6fbc to your computer and use it in GitHub Desktop.
Save natmchugh/db8e0864935b9e5d6fbc to your computer and use it in GitHub Desktop.
<?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