From cd7671672f9fe81eceb884d50866cb7f6db0dfe0 Mon Sep 17 00:00:00 2001
From: cbonar This page is a unit test. On submit, a hidden output field takes the value of the encrypted password,
+ and the password field is emptied so it is not transmitted. * Here is what the received response looks like : And after decryption : The key is either read from a file or generated on the fly if no file was found. The user types in a password, and Javascript encodes it.
+ On the server side, the message "= $plain_data ?>" would be encoded this way : Extra : On the client side, it's the same, handled in Javascript : The generated keypair was stored and retrieved for decoding : Each parameter of the request is decrypted if required :Test Page for Ciform
+
+
+ It must be open with JsUnit's TestRunner.Demo page for CiForm
+
+ 1. Fill in the following form
+
+ 2. The form is submitted with the encrypted password
+
+ Test page for Ciform
+
+ 1. Key generation
+
+ getPublicKey();
+ $math = $keyPair->_math_obj;
+ ?>
+
+
+ It is served to the client as JSON data := "var CIFORM_PUBKEY =" . ciform_rsa_pubKey2Json($keyPair) . ";" ?>
+
+
+
+ 2. Encryption on the client side
+
+ getKeyLength(),'BCMath');
+
+ $plain_data = isset($_REQUEST['out']) ? ciform_decryptParam($_REQUEST['out'],$keyPair) : "password";
+
+ // encryption (usually using public key)
+ $enc_data_base64 = $rsa->encrypt($plain_data, $keyPair->getPublicKey());
+ $enc_data_bin = base64_decode($enc_data_base64);
+ $enc_data_hex = bin2hex($enc_data_base64);
+
+ // decryption (usually using private key)
+ $dec_data = $rsa->decrypt($enc_data_base64, $keyPair->getPrivateKey());
+ ?>
+
+
+
+
+
+
+ 3. Decrypted on the server side using the same key pair
+
+
+
+ $val )
+ {
+ $dec = ciform_decryptParam($val,$keyPair);
+ if ( $key == "out" )
+ {
+ echo "KEY VALUE DECRYPTED ";
+ echo " ";
+ }
+ else
+ {
+ echo "$key ";
+ echo " ";
+ echo "" . chunk_split($val,76,"\n") . "$dec ";
+ echo "";
+ echo " ";
+ }
+ }
+ ?>$key ";
+ echo "$val ";
+ echo "$dec ";
+ echo "