colonymech / docs / www / colonyscout / internal / main.php @ f59acf11
History | View | Annotate | Download (1.35 KB)
1 | f59acf11 | Dan Shope | <?php
|
---|---|---|---|
2 | session_start(); |
||
3 | require_once("includes/jCryption-1.1.php"); |
||
4 | |||
5 | $keyLength = 256; |
||
6 | $jCryption = new jCryption(); |
||
7 | |||
8 | if(isset($_GET["generateKeypair"])) { |
||
9 | $keys = $jCryption->generateKeypair($keyLength); |
||
10 | $_SESSION["e"] = array("int" => $keys["e"], "hex" => $jCryption->dec2string($keys["e"],16)); |
||
11 | $_SESSION["d"] = array("int" => $keys["d"], "hex" => $jCryption->dec2string($keys["d"],16)); |
||
12 | $_SESSION["n"] = array("int" => $keys["n"], "hex" => $jCryption->dec2string($keys["n"],16)); |
||
13 | |||
14 | echo '{"e":"'.$_SESSION["e"]["hex"].'","n":"'.$_SESSION["n"]["hex"].'","maxdigits":"'.intval($keyLength*2/16+3).'"}'; |
||
15 | } else {
|
||
16 | ?>
|
||
17 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
18 | <html xmlns="http://www.w3.org/1999/xhtml"> |
||
19 | <head>
|
||
20 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||
21 | <title>Result</title> |
||
22 | <style type="text/css"> |
||
23 | html,body {
|
||
24 | margin:0;
|
||
25 | padding:0;
|
||
26 | font-family:Tahoma;
|
||
27 | font-size:12px;
|
||
28 | }
|
||
29 | </style>
|
||
30 | </head>
|
||
31 | <body>
|
||
32 | |||
33 | <p><strong>orignial POST:</strong> <br/><?php print_r($_POST); ?></p> |
||
34 | <?php
|
||
35 | $var = $jCryption->decrypt($_POST['jCryption'], $_SESSION["d"]["int"], $_SESSION["n"]["int"]); |
||
36 | unset($_SESSION["e"]); |
||
37 | unset($_SESSION["d"]); |
||
38 | unset($_SESSION["n"]); |
||
39 | parse_str($var,$result); |
||
40 | ?>
|
||
41 | |||
42 | <p><strong>decrypted POST:</strong> <br/><?php print_r($result); ?></p> |
||
43 | |||
44 | </body>
|
||
45 | </html>
|
||
46 | |||
47 | <?php
|
||
48 | } |
||
49 | ?> |