function encrypt($string)
{
    $key = "d0ntw0rryab0utit";
    $encoded = base64_encode($string);
    $encrypted = rc4crypt::encrypt($key, $encoded);
    return bin2hex($encrypted);
}
Exemple #2
0
 /**
  * Decryption, recall encryption
  *
  * @param string $pwd Key to decrypt with (can be binary of hex)
  * @param string $data Content to be decrypted
  * @param bool $ispwdHex Key passed is in hexadecimal or not
  * @access public
  * @return string
  */
 function decrypt($pwd, $data, $ispwdHex = 0)
 {
     return rc4crypt::encrypt($pwd, $data, $ispwdHex);
 }
\t\t\t\t\t\t</shipto_custom_field>
\t\t\t\t\t\t<shipto_custom_field>
\t\t\t\t\t\t\t<shipto_custom_field_name>More_Custom_Info</shipto_custom_field_name>
\t\t\t\t\t\t\t<shipto_custom_field_value>more of john's stuff</shipto_custom_field_value>
\t\t\t\t\t\t</shipto_custom_field>
\t\t\t\t\t</shipto_custom_fields>
\t\t\t\t</shipto_address>
\t\t\t</shipto_addresses>
\t\t</transaction>
\t</transactions>
</foxydata>
XML;
// ======================================================================================
// ENCRYPT YOUR XML
// Modify the include path to go to the rc4crypt file.
// ======================================================================================
include 'class.rc4crypt.php';
$XMLOutput_encrypted = rc4crypt::encrypt($myKey, $XMLOutput);
$XMLOutput_encrypted = urlencode($XMLOutput_encrypted);
// ======================================================================================
// POST YOUR XML TO YOUR SITE
// Do not modify.
// ======================================================================================
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $myURL);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("FoxyData" => $XMLOutput_encrypted));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
header("content-type:text/plain");
print $response;
Exemple #4
0
 /**
  * Encrypt the given value using the mcrypt library function.
  *
  * If the mcrypt functions do not exist, we fallback to the RC4 implementation which is shipped with Zikula.
  *
  * @param string  $value   The value we wish to decrypt.
  * @param string  $key     The encryption key to use (optional) (default=null).
  * @param string  $alg     The encryption algirthm to use (only used with mcrypt functions) (optional) (default=null, signifies MCRYPT_RIJNDAEL_128).
  * @param boolean $encoded Whether or not the value is base64 encoded (optional) (default=true).
  *
  * @return string The encrypted value.
  */
 public static function encrypt($value, $key = null, $alg = null, $encoded = true)
 {
     $res = false;
     $key = $key ? $key : 'ZikulaEncryptionKey';
     if (function_exists('mcrypt_create_iv') && function_exists('mcrypt_decrypt')) {
         $alg = $alg ? $alg : MCRYPT_RIJNDAEL_128;
         $iv = mcrypt_create_iv(mcrypt_get_iv_size($alg, MCRYPT_MODE_ECB), crc32($key));
         $res = mcrypt_encrypt($alg, $key, $value, MCRYPT_MODE_CBC);
     } else {
         require_once ZLOADER . '/vendor/encryption/rc4crypt.class.php';
         $res = rc4crypt::encrypt($key, $value);
     }
     return $encoded && $res ? self::encode($res) : $res;
 }
<?php

defined('_JEXEC') or die('Restricted access');
//echo 'ok';
//echo
require_once dirname(__FILE__) . '/rc4.php';
//$crypt = new Crypt_RC4();
//$rc4 = new rc4crypt();
//echo 'ok2';
//$data = "m=12&f=3&type=subscribe&email=test1@nweb.it&idl=3&ts=20120601120324";
$data = "EventDate=20120601120324&IdConsole=a6457&IdList=1&Groups=3,6&EventType=SUBSCRIBE&Email=bonetto_andrea@libero.it";
echo $data;
echo "<br><br>";
$pwd = 'provaprova';
$data = rc4crypt::encrypt($pwd, $data);
$data = base64_encode($data);
echo $data;
//echo rc4crypt::encrypt($pwd, $data);
Exemple #6
0
    }
    die("foxy");
} else {
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'process') {
        $order_id = $_REQUEST['order'];
        $find_order = $couchdb->send("/{$order_id}");
        $order = $find_order->getBodyAsObject();
        if (!$order->error) {
            try {
                $order->errors = array();
                $order->processed = isset($order->processed) ? $order->processed : array();
                foreach ($preferences->processors as $processor) {
                    $processor_name = $processor->name;
                    $order_processed = isset($order->processed->{$processor_name}) && !$order->processed->{$processor_name}->error;
                    if (!$order_processed) {
                        $XMLOutput_encrypted = urlencode(rc4crypt::encrypt($preferences->shared_secret, $order->raw_xml->data));
                        $ch = curl_init();
                        curl_setopt($ch, CURLOPT_URL, $processor->endpoint);
                        curl_setopt($ch, CURLOPT_POSTFIELDS, array("FoxyData" => $XMLOutput_encrypted));
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                        $response_body = curl_exec($ch);
                        $response = curl_getinfo($ch);
                        curl_close($ch);
                        if ($response["http_code"] != 200 || $response_body != 'foxy') {
                            $order->errors[] = array("response_code" => $response['http_code'], "message" => "Expected 200 response and 'foxy' reply, got {$response['http_code']}", "response_body" => $response_body, "processor" => $processor_name);
                        } else {
                            $order->errors = null;
                            $order->processed = array($processor_name => array("processed_at" => time(), "processor_response_body" => $response_body));
                        }
                    }
                }