(Polar Lights Labs) *most part of code ported from different *C++, JS and Flash *RSA examples found in books and in the net :) *supplied with Hacker Hunter authentication system. *http://www.polar-lights.com/hackerhunter/ *It is distributed in the hope that it will be useful, but *WITHOUT ANY WARRANTY; without even the implied warranty of *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *See the GNU General Public License for more details. *With a great thanks to: *Glenn Haecker *Segey Semenov *Suivan */ /*random generator seed */ mt_srand((double)microtime()*1000000); /* modulus function */ function mo ($g, $l) { return $g - ($l * floor ($g/$l)); } /* * ENCRYPT function returns *, X = M^E (mod N) * Please check http://www.ge.kochi-ct.ac.jp/cgi-bin-takagi/calcmodp * and Flash5 RSA .fla by R.Vijay at * http://www.digitalillusion.co.in/lab/rsaencyp.htm * It is one of the simplest examples for binary RSA calculations * * Each letter in the message is represented as its ASCII code number - 30 * 3 letters in each block with 1 in the beginning and end. * For example string *, AAA * will become *, 13535351 (A = ASCII 65-30 = 35) * we can build these blocks because the smalest prime available is 4507 *, 4507^2 = 20313049 * This means that *, 1. Modulo N will always be < 19999991 *, 2. Letters > ASCII 128 must not occur in plain text message */ function rsa_encrypt ($m, $e, $n) { $asci = array (); for ($i=0; $i> $i)>0) { if ((($exp >> $i) & 1) == 1) { $accum = mo(($accum * $basepow2) , $modulus); } $basepow2 = mo(($basepow2 * $basepow2) , $modulus); $i++; } return $accum; } ?> Guard On-Line - Contronics