newbase64 = new base64Class; $this->newXor = new simpleXorClass($keyType, $passKey); $this->arrayManipulation = new arrayManipulation; } function encryptArray($array){ if(is_array($array)){ $encyptArray = urlencode($this->newbase64->base64Encode($this->newXor->simpleXor(serialize($this->arrayManipulation->shuffleKeys($array))))); return $encyptArray; } else{ return false; } } function decryptArray($array){ $array = (strstr($array,"%")) ? urldecode($array) : $array; $decryptArray = unserialize($this->newXor->simpleXor($this->newbase64->base64Decode($array))); return $decryptArray; } function encryptString($string){ $encyptString = $this->newbase64->base64Encode( $this->newXor->simpleXor($string)); return $encyptString; } function decryptString($string){ $decyptString = $this->newXor->simpleXor($this->newbase64->base64Decode($string)); return $decyptString; } } class base64Class{ function base64Encode($plain) { return str_replace('=','', base64_encode($plain)); } function base64Decode($scrambled) { $output = ""; // Fix plus to space conversion issue $scrambled = str_replace(" ","+",$scrambled); // Do encoding $output = base64_decode($scrambled); return $output; } }// END CLASS class simpleXorClass { /* The SimpleXor encryption algorithm ** ** NOTE: This is a placeholder really. Future releases of Kaizen security will use AES or TwoFish. Proper encryption ** ** This simple function and the Base64 will deter script kiddies and prevent the "View Source" type tampering ** ** It won't stop a half decent hacker though, but the most they could do is change the fields to something ** ** else. It's still more secure than the other PSPs who don't both encrypting their forms at all ** */ function simpleXorClass($keyType=false, $passKey=false){ if(!$passKey){ $sdid = ($keyType) ? $keyType : '21'; $tbsite_definitionDAO = new tbsite_definitionDAO; $tbsite_definitionVO = $tbsite_definitionDAO->getBy_sdID($sdid,'',''); $this->thekey = $tbsite_definitionVO[0]->get_sdValue(); } else{ $this->thekey = $passKey; } } function simpleXor($InString) { $Key = $this->thekey; // Initialise key array $KeyList = array(); // Convert $Key into array of ASCII values for($i = 0; $i < strlen($Key); $i++){ $KeyList[$i] = ord(substr($Key, $i, 1)); } // Step through string a character at a time for($i = 0; $i < strlen($InString); $i++) { // Get ASCII code from string, get ASCII code from key (loop through with MOD), XOR the two, get the character from the result // % is MOD (modulus), ^ is XOR $output.= chr(ord(substr($InString, $i, 1)) ^ ($KeyList[$i % strlen($Key)])); } return $output; }// END FUNCTION }// END CLASS ?>