<?php $come['groups']['0']['en_titl'] = "featured"; $come['groups']['0']['ar_titl'] = "featuredAR"; $come['groups']['0']['content'] = "content"; $come['groups']['2']['en_titl'] = "featured"; $come['groups']['2']['ar_titl'] = "featuredAR"; $come['groups']['2']['content'] = "content"; $come['groups']['3']['en_titl'] = "featured"; $come['groups']['3']['ar_titl'] = "featuredAR"; $come['groups']['3']['content'] = "content"; print_r($come); ?>
<?php /* * This class is also provided to a third party so any changes made in this class needs to be escalated for updating. * */ class McryptUtil { private $key; private $resMKript; // private $twoWayHash; here we mean same text encrypts to same cipher every time you apply this method. private $blockSize; public function __construct($key, $algo) { // $this->key = $key; // $this->resMKript = mcrypt_module_open($algo, '', 'cbc', ''); // $this->blockSize = mcrypt_enc_get_block_size($this->resMKript); //NOTE: for twoWayHash, we can use mode 'ecb' with out static 'iv'. but the issue is 'ecb' is little slower than 'cbc' //so we are using 'cbc' with static 'iv' for twoWayHashes } private function getIV() { $iv_size = mcrypt_enc_get_iv_size($this->resMKript); $iv = ''; if(true) { for($i = 0; $i < $iv_size; $i++ ) { $iv .= 'X'; } } else { $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($this->resMKript), mt_rand()); } return $iv; } private function prependIVtoTheCipher($iv, $cipher) { return $iv.$cipher; } private function seperateCipherAndIV($cipher) { $data['iv'] = substr($cipher, 0, mcrypt_enc_get_iv_size($this->resMKript)); $data['cipher'] = substr($cipher, mcrypt_enc_get_iv_size($this->resMKript)); if($data['iv'] != $this->getIV()) { $data['iv'] = $this->getIV(); $data['cipher'] = $cipher; } else { //my_var_dump("IV found in cipher"); } return $data; } /** * returns encrypted binary string. * @param input data in binary string format */ private function encrypt($input) { //we need to create 'iv' everytime we try to encrypt data. $iv = $this->getIV(); //before u do any encryption/decryption, you have to initialise module with key and iv mcrypt_generic_init($this->resMKript, $this->key, $iv); //now encrypt the data. before that, compress it to have the cipher compact. $input= $this->_gzdeflate($input); //padding with \c, c = number of bytes needed to complete the last block //to ensure the same padding in node and php $pad = $this->blockSize - (strlen($input) % $this->blockSize); $input = $input . str_repeat(chr($pad), $pad); $cipher = mcrypt_generic($this->resMKript,$input); return $cipher; } /** * returns decrypted data. remember to pass base64 decoded data. * * @param base64 decoded data * @return plain text if successful */ private function decrypt($cipher) { //get the cipher and iv $cipherData = $this->seperateCipherAndIV($cipher); //initialise the module mcrypt_generic_init($this->resMKript, $this->key, $cipherData['iv']); //decrypt $decryptedData = mdecrypt_generic($this->resMKript, $cipherData['cipher']); //uncompress $uncompressedData = $this->_gzinflate($decryptedData); if($uncompressedData === false) { ExceptionFactory::throwCryptographyException('data could not be uncompressed'); } return $uncompressedData; } private function _gzdeflate($input) { return gzdeflate($input); } private function _gzinflate($input) { return gzinflate($input); } public function encodeMime($input) { $enc = $this->encrypt($input); $encodedString= base64_encode($enc); $replaceArray = array('+'=>'-','/'=>'_'); return strtr($encodedString, $replaceArray); } public function decodeMime($mimeEncodedCipher) { $transArray = array('-'=>'+','_'=>'/'); $mimeEncodedCipher = strtr($mimeEncodedCipher, $transArray); if( !isStringSet( $mimeEncodedCipher ) ) { return null; } $binaryString = base64_decode($mimeEncodedCipher); $decodedMime = $this->decrypt($binaryString); echo $decodedMime; return $decodedMime; } public function __destruct() { if($this->resMKript) { mcrypt_module_close($this->resMKript); } } } $o = 'b1S17e7MpHrNbIp37_Oqy1MpcchQ9FZb_FZ6z91JJnwzBcVPaS8C4cEMSbeL6NIeaaieG1pKB9v8Y0h7XnHE3Ot9BJpaJ5nDbhJ5cg3acY-ej8-E_YvSzyWaeqn7X7gOXLLQYKg1jyR87RqCxZU_wsHi7T4KyejlcB3tbpXPUOd1G1YAigRQudIhmIwCBsedlxRq5UvgyoYpELCa9QoRBScWq-CbMLBVpbguujNsHofC7AKaIuW5IK5h06-n97-HxPBKCIOIhFWH3fhbNJMD-bfzJgA48NlGK5hwCBvc2T-SLrN2g9eWimOwqpnyywxBrIBO2T9XS_36wVd5P6uspQdYyCrhY-nILlQvArmXGI2nPHxr8Ru65325Ioyzx_41Cwxx0-Ju6e4SHpSfphL5eTzK3btxqCbSOpkwFKiTD-EMF_rxzr1tdaGu0v8HESTYZtala9psUuHWx7BXcncMjlTWKbvmR_T409MWiZEfdoE2ZZYv_J8zEjBNuNpAXd3VwZHu641o4vS4_COnfsqe-6aTtsm1xYgltecJvlWJDKcv5jrYFybSMXp1u0Cw9nY1056ADGGHpZURFPGZ5JkxvziWc9O-gk5BNBwyaVjfI6MN8v3jcI3Gcz9aCLxKWa7WB5XvmRMhjrmv5yZpXOlk3mYrcSdmAZLvdvRyQmOf-04zVJoLQjTfAIig32OKzR_NTBKjBU_FVf7jWrGomE_N7i4HAerBXwSKgmhvYSwEQLbXIKTvMqdOxjlFp0vCqLglaAhZgeH82wEJGlN4vvuo0T0sw6PQsqXgNrS0h43pc1B58X-sSDZhbafrweyyv7N0Bc5Sp3QGY6o='; $obj = new McryptUtil("key", "algo"); $decodedMime = $obj->decodeMime($o); ?>
<html> <head> <title>Online PHP Script Execution</title> </head> <body> <?php hello ?> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more