This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

first commit

  • Loading branch information...
HazAT committed Dec 28, 2010
0 parents commit ec7cd32d5479231e8bbb56ec083f536458d132b2
0 README
No changes.
@@ -0,0 +1,98 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>Example 1</title>
+ <style type="text/css">
+ html,body {
+ margin:0;
+ padding:0;
+ font-family:Tahoma;
+ font-size:12px;
+ }
+ input,textarea,select {
+ font-family:Tahoma;
+ font-size:12px;
+ }
+ </style>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ <script type="text/javascript" src="../../jquery.jcryption-1.1.js" ></script>
+ <script type="text/javascript">
+
+ $.fn.fillInForm = function() {
+ $(this).find("a[href='#fillWithSamples']").click(function() {
+ $parentForm = $(this).closest("form");
+ $parentForm.find(":radio:eq(0)").attr("checked","checked");
+ $parentForm.find("input[name='Firstname']").val("John");
+ $parentForm.find("input[name='Lastname']").val("Wayne");
+ $parentForm.find("input[name='Email']").val("john@wayne.cc");
+ $parentForm.find(":checkbox:eq(2)").attr("checked","checked");
+ $parentForm.find("select[name='age']").val("over 30");
+ $parentForm.find("select[name='likes[]']").children("option:eq(0),option:eq(1),option:eq(3)").attr("selected","selected")
+ return false;
+ });
+ };
+
+ $(function() {
+ // Just the from filling code
+ $("#normal").fillInForm();
+ $(":input").removeAttr("disabled");
+ // --------------------------
+
+ $("#normal").jCryption();
+ });
+ </script>
+ </head>
+
+ <body>
+ <form id="normal" class="general" action="main.php" method="post"> <fieldset>
+
+ <strong><a href="#fillWithSamples" style="color:#000000;">fill with samples &raquo;</a></strong>
+ <table border="0" cellspacing="5" cellpadding="0">
+ <tbody>
+ <tr>
+ <td>Sex:</td>
+ <td><input class="radio" name="Sex" type="radio" value="male" />Male
+
+ <input class="radio" name="Sex" type="radio" value="female" />Female</td>
+ </tr>
+ <tr>
+ <td>Firstname:</td>
+ <td><input class="text" name="Firstname" type="text" /></td>
+ </tr>
+ <tr>
+ <td>Lastname:</td>
+ <td><input class="text" name="Lastname" type="text" /></td>
+ </tr>
+ <tr>
+ <td>E-Mail:</td>
+ <td><input class="text" name="Email" type="text" /></td>
+ </tr>
+ <tr>
+ <td>What would you like to eat?</td>
+ <td><input class="checkbox" name="Food[]" type="checkbox" value="pizza" />Pizza
+
+ <input class="checkbox" name="Food[]" type="checkbox" value="hamburger" />Hamburger
+
+ <input class="checkbox" name="Food[]" type="checkbox" value="salad" />Salad
+
+ <input class="checkbox" name="Food[]" type="checkbox" value="steak" />Steak</td>
+ </tr>
+ <tr>
+ <td>Age:</td>
+ <td><select name="age"> <option value="under 18">under 18</option> <option value="over 18">over 18</option> <option value="over 30">over 30</option> </select></td>
+ </tr>
+ <tr valign="top">
+ <td valign="top">I like (you can select more than one):</td>
+ <td><select name="likes[]" size="5" multiple="multiple"> <option value="Michael Jackson">Michael Jackson</option> <option value="rainy wheater">rainy wheater</option> <option value="a hot summer">a hot summer</option> <option value="small cats">small cats</option> <option value="funny movies">funny movies</option> <option value="I like everything">I like everything</option> </select></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td><input title="Submit" alt="Submit" name="submitButton" type="submit" value="Submit" class="submit" /> <input title="Reset" alt="Reset" name="reset" type="reset" value="Reset" /></td>
+ </tr>
+ </tbody>
+ </table>
+ </fieldset>
+ </form>
+ </body>
+</html>
@@ -0,0 +1,47 @@
+<?php
+session_start();
+require_once("../../jCryption-1.1.php");
+$keyLength = 256;
+$jCryption = new jCryption();
+if(isset($_GET["generateKeypair"])) {
+ $keys = $jCryption->generateKeypair($keyLength);
+ $_SESSION["e"] = array("int" => $keys["e"], "hex" => $jCryption->dec2string($keys["e"],16));
+ $_SESSION["d"] = array("int" => $keys["d"], "hex" => $jCryption->dec2string($keys["d"],16));
+ $_SESSION["n"] = array("int" => $keys["n"], "hex" => $jCryption->dec2string($keys["n"],16));
+
+ echo '{"e":"'.$_SESSION["e"]["hex"].'","n":"'.$_SESSION["n"]["hex"].'","maxdigits":"'.intval($keyLength*2/16+3).'"}';
+} else {
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Result</title>
+<style type="text/css">
+html,body {
+ margin:0;
+ padding:0;
+ font-family:Tahoma;
+ font-size:12px;
+}
+</style>
+</head>
+<body>
+
+<p><strong>orignial POST:</strong> <br/><?php print_r($_POST); ?></p>
+<?php
+$var = $jCryption->decrypt($_POST['jCryption'], $_SESSION["d"]["int"], $_SESSION["n"]["int"]);
+unset($_SESSION["e"]);
+unset($_SESSION["d"]);
+unset($_SESSION["n"]);
+parse_str($var,$result);
+?>
+
+<p><strong>decrypted POST:</strong> <br/><?php print_r($result); ?></p>
+
+</body>
+</html>
+
+<?php
+}
+?>
@@ -0,0 +1,104 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>Example 2</title>
+ <style type="text/css">
+ html,body {
+ margin:0;
+ padding:0;
+ font-family:Tahoma;
+ font-size:12px;
+ }
+ input,textarea,select {
+ font-family:Tahoma;
+ font-size:12px;
+ }
+ </style>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ <script type="text/javascript" src="../../jquery.jcryption-1.1.js" ></script>
+ <script type="text/javascript">
+
+ $.fn.fillInForm = function() {
+ $(this).find("a[href='#fillWithSamples']").click(function() {
+ $parentForm = $(this).closest("form");
+ $parentForm.find(":radio:eq(0)").attr("checked","checked");
+ $parentForm.find("input[name='Firstname']").val("John");
+ $parentForm.find("input[name='Lastname']").val("Wayne");
+ $parentForm.find("input[name='Email']").val("john@wayne.cc");
+ $parentForm.find(":checkbox:eq(2)").attr("checked","checked");
+ $parentForm.find("select[name='age']").val("over 30");
+ $parentForm.find("select[name='likes[]']").children("option:eq(0),option:eq(1),option:eq(3)").attr("selected","selected")
+ return false;
+ });
+ };
+
+ $(function() {
+
+ var $status = $('<div id="status" style="margin-top:15px;"><img src="loading.gif" alt="Loading..." title="Loading..." style="margin-right:15px;" /><span>Encrypting</span></div>').hide();
+ $("#submitButton").parent().append($status);
+
+ $("#callbackForm").jCryption({
+ beforeEncryption:function() {
+ $status.show();
+ return true;
+ }
+ }).find("fieldset").fillInForm();
+
+ $(":input").removeAttr("disabled");
+
+ });
+ </script>
+ </head>
+
+ <body><form action="main.php" method="post" id="callbackForm" class="general">
+ <fieldset>
+ <strong><a href="#fillWithSamples" style="color:#000000;">fill with samples &raquo;</a></strong>
+ <table border="0" cellspacing="5" cellpadding="0">
+ <tbody>
+ <tr>
+ <td>Sex:</td>
+ <td><input class="radio" name="Sex" type="radio" value="male" />Male
+
+ <input class="radio" name="Sex" type="radio" value="female" />Female</td>
+ </tr>
+ <tr>
+ <td>Firstname:</td>
+ <td><input class="text" name="Firstname" type="text" /></td>
+ </tr>
+ <tr>
+ <td>Lastname:</td>
+ <td><input class="text" name="Lastname" type="text" /></td>
+ </tr>
+ <tr>
+ <td>E-Mail:</td>
+ <td><input class="text" name="Email" type="text" /></td>
+ </tr>
+ <tr>
+ <td>What would you like to eat?</td>
+ <td><input class="checkbox" name="Food[]" type="checkbox" value="pizza" />Pizza
+
+ <input class="checkbox" name="Food[]" type="checkbox" value="hamburger" />Hamburger
+
+ <input class="checkbox" name="Food[]" type="checkbox" value="salad" />Salad
+
+ <input class="checkbox" name="Food[]" type="checkbox" value="steak" />Steak</td>
+ </tr>
+ <tr>
+ <td>Age:</td>
+ <td><select name="age"> <option value="under 18">under 18</option> <option value="over 18">over 18</option> <option value="over 30">over 30</option> </select></td>
+ </tr>
+ <tr valign="top">
+ <td valign="top">I like (you can select more than one):</td>
+ <td><select name="likes[]" size="5" multiple="multiple"> <option value="Michael Jackson">Michael Jackson</option> <option value="rainy wheater">rainy wheater</option> <option value="a hot summer">a hot summer</option> <option value="small cats">small cats</option> <option value="funny movies">funny movies</option> <option value="I like everything">I like everything</option> </select></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td><input title="Submit" alt="Submit" name="submitButton" type="submit" value="Submit" class="submit" id="submitButton" /> <input title="Reset" alt="Reset" name="reset" type="reset" value="Reset" /></td>
+ </tr>
+ </tbody>
+ </table>
+ </fieldset>
+ </form>
+ </body>
+</html>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,49 @@
+<?php
+session_start();
+require_once("../../jCryption-1.1.php");
+
+$keyLength = 256;
+$jCryption = new jCryption();
+
+if(isset($_GET["generateKeypair"])) {
+ $keys = $jCryption->generateKeypair($keyLength);
+ $_SESSION["e"] = array("int" => $keys["e"], "hex" => $jCryption->dec2string($keys["e"],16));
+ $_SESSION["d"] = array("int" => $keys["d"], "hex" => $jCryption->dec2string($keys["d"],16));
+ $_SESSION["n"] = array("int" => $keys["n"], "hex" => $jCryption->dec2string($keys["n"],16));
+
+ echo '{"e":"'.$_SESSION["e"]["hex"].'","n":"'.$_SESSION["n"]["hex"].'","maxdigits":"'.intval($keyLength*2/16+3).'"}';
+} else {
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Result</title>
+<style type="text/css">
+html,body {
+ margin:0;
+ padding:0;
+ font-family:Tahoma;
+ font-size:12px;
+}
+</style>
+</head>
+<body>
+
+<p><strong>orignial POST:</strong> <br/><?php print_r($_POST); ?></p>
+<?php
+$var = $jCryption->decrypt($_POST['jCryption'], $_SESSION["d"]["int"], $_SESSION["n"]["int"]);
+unset($_SESSION["e"]);
+unset($_SESSION["d"]);
+unset($_SESSION["n"]);
+parse_str($var,$result);
+?>
+
+<p><strong>decrypted POST:</strong> <br/><?php print_r($result); ?></p>
+
+</body>
+</html>
+
+<?php
+}
+?>
@@ -0,0 +1,17 @@
+<?php
+ session_start();
+ require_once("../../jCryption-1.1.php");
+ $keyLength = 256;
+ $jCryption = new jCryption();
+ if(isset($_GET["generateKeypair"])) {
+ $keys = $jCryption->generateKeypair($keyLength);
+ $_SESSION["e"] = array("int" => $keys["e"], "hex" => $jCryption->dec2string($keys["e"],16));
+ $_SESSION["d"] = array("int" => $keys["d"], "hex" => $jCryption->dec2string($keys["d"],16));
+ $_SESSION["n"] = array("int" => $keys["n"], "hex" => $jCryption->dec2string($keys["n"],16));
+
+ echo '{"e":"'.$_SESSION["e"]["hex"].'","n":"'.$_SESSION["n"]["hex"].'","maxdigits":"'.intval($keyLength*2/16+3).'"}';
+ } else {
+ $var = $jCryption->decrypt($_POST['jCryption'], $_SESSION["d"]["int"], $_SESSION["n"]["int"]);
+ echo $var;
+ }
+?>
@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>Example 1</title>
+ <style type="text/css">
+ html,body {
+ margin:0;
+ padding:0;
+ font-family:Tahoma;
+ font-size:12px;
+ }
+ input,textarea,select {
+ font-family:Tahoma;
+ font-size:12px;
+ }
+ </style>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ <script type="text/javascript" src="../../jquery.jcryption-1.1.min.js"></script>
+ <script type="text/javascript">
+ var $loader = $('<img src="loading.gif" alt="Loading..." title="Loading..." style="margin-right:15px;" />');
+ $(function() {
+
+ var keys;
+ $.jCryption.getKeys("encrypt.php?generateKeypair=true",function(receivedKeys) {
+ keys = receivedKeys;
+ $("#toEncrypt").attr("disabled",false);
+ $("#encrypt").attr("disabled",false);
+ $("#status").html('<span style="font-size: 16px;">Ready to encrypt</span>');
+ });
+
+ $("#encrypt").click(function() {
+ $.jCryption.encrypt($("#toEncrypt").val(),keys,function(encrypted) {
+ $("#toDecrypt").val(encrypted);
+ });
+ });
+
+ $("#decrypt").click(function() {
+ $("#result").html($loader);
+ $.ajax({
+ type: 'POST',
+ url: "encrypt.php",
+ data: {jCryption:$("#toDecrypt").val()},
+ success: function(data) {
+ $("#result").html(data);
+ }
+ });
+ });
+
+ });
+ </script>
+ </head>
+
+ <body>
+ <p id="status"><span style="font-size: 16px;">Waiting for Keys</span> <img src="loading.gif" alt="Loading..." title="Loading..." style="margin-right:15px;" /></p>
+ String: <input type="text" id="toEncrypt" disabled="disabled" /> <button id="encrypt" disabled="disabled">Encrypt</button><br/>
+ Encrypted String:<br/>
+ <textarea cols="40" rows="5" id="toDecrypt"></textarea><br/><button id="decrypt">Decrypt</button><br/><br/>
+ Decrypted:<p id="result"></p>
+ </body>
+</html>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit ec7cd32

Please sign in to comment.