function decryptCookie($value) { if (!$value) { return false; } $value = base64_decode($value); $cookiedough = unserialize($value); // generate an SHA-256 HMAC hash where data = encrypted text and key = defined constant $snifftest = hash_hmac('sha256', $cookiedough['text'], SIG_HMAC); // if it matches the stored signature, you pass. if (!($cookiedough['sig'] == $snifftest)) { die("Oops! It looks like something went wrong with your browser cookies. Please ensure that cookies are enabled in your browser. If the problem persists, please notify your library."); } // generate an SHA-256 HMAC hash where data = session ID and key = defined constant $key = hash_hmac('sha256', session_id(), ENCRYPTION_KEY_HMAC); if (strlen($key) > 24) { $key = substr($key, 0, 24); } $iv = $cookiedough['iv']; $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $cookiedough['text'], MCRYPT_MODE_CBC, $iv); $data = @unserialize($decrypttext); if ($decrypttext === 'b:0;' || $data !== false) { $decrypttext = $data; } if (is_array($decrypttext)) { return $decrypttext; } else { return trim($decrypttext); } }
function DecryptString($str) { $hash = hash('sha512', 'Imp3ro', true); $key = substr($hash, 0, 0x20); $iv = substr($hash, 0x20, 0x10); return UnPadString(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, 'cbc', $iv)); }
/** * @param string $encryptedText * @return string */ public function decrypt($encryptedText) { $encryptedTextDecoded = base64_decode($encryptedText); $ivDecoded = substr($encryptedTextDecoded, 0, $this->size); $encryptedTextDecoded = substr($encryptedTextDecoded, $this->size); return trim(mcrypt_decrypt($this->cypher, $this->key, $encryptedTextDecoded, $this->mode, $ivDecoded)); }
private static function _decrypt($value, $key) { $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($value), MCRYPT_MODE_ECB, $iv); return trim($decrypttext); }
function decrypt($encrypted_string, $encryption_key) { $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, $encryption_key, base64_decode($encrypted_string), MCRYPT_MODE_ECB, $iv); return $decrypted_string; }
public static function DecryptString($key, $iv, $dec) { if (is_null($key) || is_null($iv) || is_null($dec)) { return $dec; } return base64_decode(mcrypt_decrypt(CRYPTO_METHOD, $key, $dec, CRYPTO_MODE, $iv)); }
function getLoginCookie() { //voodoo list($encryptedData, $iv) = explode(":", $_COOKIE["usr"]); $rawData = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, getSecret(), base64_decode($encryptedData), MCRYPT_MODE_CBC, $iv); return unserialize($rawData); }
/** * Decrypt string * * NOTICE: the code in general, this method in particular, comes with absolutely no warranty. If security is * important for you, then use a purpose built package. https://github.com/defuse/php-encryption seems like * a good candidate. * @deprecated Do not trust a two-line decryption-method. * * @param string $string String to decrypt * @param string $key Key to encrypt/decrypt. * @return string Decrypted string */ public static function decrypt($string, $key) { $encryptedString = base64_decode($string); $initializationVector = substr($encryptedString, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB)); $decryptedString = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, hash("sha256", $key, true), substr($encryptedString, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB)), MCRYPT_MODE_CBC, $initializationVector), ""); return $decryptedString; }
/** * * Decrypt a string (Passwords) * * @param string $string value to decrypt * * @return string decrypted string */ public static function decrypt($string) { if (empty($string)) { return $string; } if (strpos($string, '$BackWPup$ENC1$O$') !== FALSE || strpos($string, '$BackWPup$RIJNDAEL$O$') !== FALSE) { $key_type = 'O$'; $key = BACKWPUP_ENC_KEY; } else { $key_type = ''; $key = DB_NAME . DB_USER . DB_PASSWORD; } $key = md5($key); if (strpos($string, '$BackWPup$ENC1$' . $key_type) !== FALSE) { $string = str_replace('$BackWPup$ENC1$' . $key_type, '', $string); $result = ''; $string = base64_decode($string); for ($i = 0; $i < strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr($key, $i % strlen($key) - 1, 1); $char = chr(ord($char) - ord($keychar)); $result .= $char; } return $result; } if (function_exists('mcrypt_encrypt') && strpos($string, '$BackWPup$RIJNDAEL$' . $key_type) !== FALSE) { $string = str_replace('$BackWPup$RIJNDAEL$' . $key_type, '', $string); return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), ""); } return $string; }
function decryptWrapper($string) { global $encryptKey; $string = base64_decode($string); $string = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $encryptKey, $string, MCRYPT_MODE_CBC, base64_decode($this->iv)); return trim($string); }
public static function decrypt($cipher, $key, $hmacSalt = null) { self::_checkKey($key, 'decrypt()'); if (empty($cipher)) { echo 'The data to decrypt cannot be empty.'; die; } if ($hmacSalt === null) { $hmacSalt = self::$salt; } $key = substr(hash('sha256', $key . $hmacSalt), 0, 32); # Generate the encryption and hmac key. # Split out hmac for comparison $macSize = 64; $hmac = substr($cipher, 0, $macSize); $cipher = substr($cipher, $macSize); $compareHmac = hash_hmac('sha256', $cipher, $key); if ($hmac !== $compareHmac) { return false; } $algorithm = MCRYPT_RIJNDAEL_128; # encryption algorithm $mode = MCRYPT_MODE_CBC; # encryption mode $ivSize = mcrypt_get_iv_size($algorithm, $mode); # Returns the size of the IV belonging to a specific cipher/mode combination $iv = substr($cipher, 0, $ivSize); $cipher = substr($cipher, $ivSize); $plain = mcrypt_decrypt($algorithm, $key, $cipher, $mode, $iv); return rtrim($plain, ""); }
/** * Get ``$_POST`` or ``$_REQUEST`` vars from ClickBank. * * @package s2Member\ClickBank * @since 140806 * * @return array|bool An array of verified ``$_POST`` or ``$_REQUEST`` variables, else false. */ public static function clickbank_postvars() { if (!empty($_REQUEST['s2member_pro_clickbank_return']) && !empty($_REQUEST['cbpop'])) { $postvars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_REQUEST)); foreach ($postvars as $var => $value) { if (preg_match('/^s2member_/', $var)) { unset($postvars[$var]); } } $cbpop = $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_clickbank_secret_key']; $cbpop .= '|' . $postvars['cbreceipt'] . '|' . $postvars['time'] . '|' . $postvars['item']; $mb = function_exists('mb_convert_encoding') ? @mb_convert_encoding($cbpop, 'UTF-8', $GLOBALS['WS_PLUGIN__']['s2member']['c']['mb_detection_order']) : $cbpop; $cbpop = $mb ? $mb : $cbpop; // Double check this, just in case conversion fails. $cbpop = strtoupper(substr(sha1($cbpop), 0, 8)); if ($postvars['cbpop'] === $cbpop) { return $postvars; } } else { if (!empty($_REQUEST['s2member_pro_clickbank_notify']) && is_object($input = json_decode(file_get_contents('php://input')))) { $encryption_iv = base64_decode($input->iv); $encrypted_notification = base64_decode($input->notification); $key = substr(sha1($GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_clickbank_secret_key']), 0, 32); $decrypted_notification = trim(trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted_notification, MCRYPT_MODE_CBC, $encryption_iv), "..")); if (function_exists('mb_convert_encoding')) { $decrypted_notification = mb_convert_encoding($decrypted_notification, 'UTF-8', $GLOBALS['WS_PLUGIN__']['s2member']['c']['mb_detection_order']); } if ($decrypted_notification && ($postvars = (array) json_decode($decrypted_notification))) { return $postvars; } } } return FALSE; }
/** * Decodes the base-64 encoded ciphher text, decrypts it and unpads the PKCS5. * * @param string $cipherText the base 64 encoded cipher text * @access public * @return string plain text */ public function decrypt($cipherText) { $cipherText = base64_decode($cipherText); $plainText = mcrypt_decrypt(MCRYPT_BLOWFISH, $this->key, $cipherText, MCRYPT_MODE_CBC, $this->iv); $plainText = rtrim($plainText); return $this->unpadPKCS5($plainText); }
function a2b_decrypt($text, $key) { $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size); $temp = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), $text, MCRYPT_MODE_ECB, $iv); return $temp; }
protected function pageDecoder() { if (preg_match('@file\\s*:\\s*"((?:[0-9a-fA-F]{2})+)"@i', $this->page, $encoded)) { $encoded = $encoded[1]; $this->page = str_replace($encoded, rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, pack('H*', 'a949376e37b369f17bc7d3c7a04c5721'), pack('H*', $encoded), MCRYPT_MODE_ECB)), $this->page); } }
public static function decrypt($text, $key = '') { if (!$text) { return ''; } return @mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, pack("H*", $text), MCRYPT_MODE_ECB); }
function _output($value) { // Get the postmeta if (!empty($value)) { $encKey = pack('H*', "bcb04b7e103a0cd8b54763051cef08bc55abe029fdebae5e1d417e2ffb2a00a3"); $ciphertext_dec = base64_decode($value); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $iv_dec = substr($ciphertext_dec, 0, $iv_size); $ciphertext_dec = substr($ciphertext_dec, $iv_size); $plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $encKey, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec); $value = rtrim($plaintext_dec); } $output = ''; $output .= '<div class="cuztom-checkboxes-wrap" ' . $this->output_data_attributes() . '>'; if (is_array($this->options)) { foreach ($this->options as $slug => $name) { if (!empty($value)) { $checked = $slug == $value ? 'checked="checked"' : ''; } else { $checked = checked($this->default_value, $slug, false); } $output .= '<input type="radio" ' . $this->output_name() . ' ' . $this->output_id($this->id . $this->after_id . '_' . Cuztom::uglify($slug)) . ' ' . $this->output_css_class() . ' value="' . $slug . '" ' . $checked . ' /> '; $output .= '<label ' . $this->output_for_attribute($this->id . $this->after_id . '_' . Cuztom::uglify($slug)) . '">' . Cuztom::beautify($name) . '</label>'; $output .= '<br />'; } } $output .= '</div>'; $output .= $this->output_explanation(); return $output; }
function decryptData($value, $filename, $name, $downloadBothMMStartTime) { //vale : encrypted data and filename : to decrypt file //AES 128-bit decryption $key = "Mary has one cat"; $crypttext = $value; $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $crypttext, MCRYPT_MODE_ECB, $iv); //writing to file filename.txt.decrypt $myfile = fopen("C:\\xampp\\htdocs\\BEPROJECT\\Html\\Decrypt/" . $name . ".decrypt", "w") or die("Unable to open file!"); fwrite($myfile, $decrypttext); $decrypt_file = $name . '.decrypt'; $storage = array(); $partialName = array(); $storage = explode("_", $name); //abc_mp3.txt $actualName = $storage[0]; //abc $tailName = $storage[1]; //mp3.txt $partialName = explode(".", $storage[1]); $extensionName = $partialName[0]; //mp3 $fullName = $actualName . "." . $extensionName; //abc.mp3 $fileNames = array('\\Multimedia/' . $fullName, '\\Decrypt/' . $decrypt_file); $zip_file_name = $actualName . '.zip'; $file_path = dirname(__FILE__); //echo "<br>".$file_path; zipFilesDownload($fileNames, $zip_file_name, $file_path, $downloadBothMMStartTime); fclose($myfile); }
public function decryptMessage($sel) { $data = base64_decode($this->getMessage()); $iv = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, hash('sha256', $sel, true), substr($data, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)), MCRYPT_MODE_CBC, $iv), ""); return $decrypted; }
public function decrypt($string, $cryptoKey) { list($key, $iv) = $this->splitKeyIv($cryptoKey); $ret = mcrypt_decrypt($this->cryptoAlgo, $key, base64_decode($string), $this->cipherMode, $iv); // Remove padding return trim($ret, ".."); }
function _output($value) { if (!isset($this->options) || !isset($this->options['meta_field']) || empty($this->options['meta_field'])) { // no value to show return ''; } global $post; $metaValue = get_post_meta($post->ID, $this->options['meta_field'], true); $value = $metaValue . ' <input type="hidden" name="cuztom[' . $this->name . ']" id="' . $this->id . '" value="' . $metaValue . '" />'; if (empty($metaValue)) { return ''; } if (isset($this->options) || isset($this->options['type']) && !empty($this->options['type'])) { // Deal with special types switch (strtolower($this->options['type'])) { case 'encrypted': $encKey = pack('H*', NM_ENCRYPTION_KEY); $ciphertext_dec = base64_decode($metaValue); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $iv_dec = substr($ciphertext_dec, 0, $iv_size); $ciphertext_dec = substr($ciphertext_dec, $iv_size); $plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $encKey, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec); $value = $plaintext_dec; break; case 'currency': $value = '$' . number_format((double) $metaValue, 2); break; case 'payment_option': $value = get_term($metaValue, 'payment_options')->name; break; } } return $value; }
/** * This is the main method that is called when a task is executed * It MUST be implemented by all classes inheriting from this one * Note that there is no error handling, errors and failures are expected * to be handled and logged by the client implementations. * Should return true on successful execution, false on error. * * @return boolean Returns true on successful execution, false on error */ public function execute() { $success = false; $this->init(); /** @var \TYPO3\CMS\Core\Registry $registry */ $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry'); $syncLock = $registry->get(static::$package, 'synchronisationLock'); $content = GeneralUtility::getUrl($this->config['masterUrl']); if ($content && ($syncLock === 0 || $syncLock < time())) { $lockUntil = time() - $this->config['updateInterval'] + self::LOCK_INTERVAL; $registry->set(static::$package, 'synchronisationLock', $lockUntil); $response = json_decode($content, true); if ($response['success']) { $key = $this->config['preSharedKey']; $encrypted = $response['data']; $data = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), ""); $records = json_decode($data, true); if (count($records)) { $this->synchronizeUsers($records); $success = true; } else { GeneralUtility::sysLog('No users to be synchronized', self::$extKey, 3); } } else { GeneralUtility::sysLog($response['errors'][0], self::$extKey, 3); } $registry->set(static::$package, 'synchronisationLock', 0); } return $success; }
/** * Decryption using blowfish algorithm (mcrypt) * * @param string $encdata encrypted data * @param string $secret the secret * * @return string original data * * @access public * */ function PMA_blowfish_decrypt($encdata, $secret) { global $iv; $data = base64_decode($encdata); $decrypted = mcrypt_decrypt(MCRYPT_BLOWFISH, $secret, $data, MCRYPT_MODE_CBC, $iv); return trim($decrypted); }
static function decrypt($string, $date = 0) { if (empty($string)) { return ''; } $key = self::_getKey($date); if (!empty($key)) { $ciphertext_dec = base64_decode($string); if (function_exists('mcrypt_encrypt')) { $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); //vmdebug('decrypt $iv_size', $iv_size ,MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); // retrieves the IV, iv_size should be created using mcrypt_get_iv_size() $iv_dec = substr($ciphertext_dec, 0, $iv_size); //retrieves the cipher text (everything except the $iv_size in the front) $ciphertext_dec = substr($ciphertext_dec, $iv_size); vmdebug('decrypt $iv_dec', $iv_dec, $ciphertext_dec); if (empty($iv_dec) and empty($ciphertext_dec)) { vmdebug('Seems something not encrytped should be decrypted, return default ', $string); return $string; } else { $mcrypt_decrypt = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec); return rtrim($mcrypt_decrypt, ""); } } else { return $ciphertext_dec; } } else { return $string; } }
public static function decode($decrypt, $key) { $decoded = base64_decode($decrypt); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_DES, MCRYPT_MODE_ECB), MCRYPT_RAND); $decrypted = mcrypt_decrypt(MCRYPT_DES, $key, $decoded, MCRYPT_MODE_ECB, $iv); return $decrypted; }
function decryptRJ256($key, $iv, $string_to_decrypt) { $string_to_decrypt = base64_decode($string_to_decrypt); $rtn = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $string_to_decrypt, MCRYPT_MODE_CBC, $iv); $rtn = rtrim($rtn, ""); return $rtn; }
function login() { $this->log("login"); $email = get_option('sk_account'); $password = get_option('sk_password'); delete_option('sk_auto_activation_error'); if (!$password || !$email) { return false; } $key = 'hash'; $decrypted_password = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($password), MCRYPT_MODE_CBC, md5(md5($key))), ""); $result = $this->login_request(array('email' => $email, 'password' => $decrypted_password)); if (!isset($result) || !isset($result->success) || isset($result->response->message) && $result->response->message == 'Unauthorized') { if (isset($result->message)) { update_option('sk_auto_activation_error', $result->message); $this->log("login: false -> {$result->message}"); } else { $this->log("login: false"); } delete_option('sk_token'); return false; } else { $this->log("login: true -> saving token " . $result->payload->token->value); delete_option('sk_auto_activation_error'); set_transient('sk_token', $result->payload->token->value, 24 * HOUR_IN_SECONDS); $this->load_subscriptions($result->payload->token->value); return $result->payload->token->value; } }
public static function decrypted($encrypted, $key) { $data = base64_decode($encrypted); $iv = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)); $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, hash('sha256', $key, true), substr($data, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)), MCRYPT_MODE_CBC, $iv), ""); return $decrypted; }
function decrypt($text, $salt) { if (!function_exists('mcrypt_encrypt') || !function_exists('mcrypt_decrypt')) { return $text; } return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))); }
function decrypt($string, $salt = ENCRYPT_PASSWORD_SALT) { # decryptes encrypted string $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($salt), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($salt))), ""); #gives back the string return $decrypted; }