本文整理汇总了PHP中mcrypt_decrypt函数的典型用法代码示例。如果您正苦于以下问题:PHP mcrypt_decrypt函数的具体用法?PHP mcrypt_decrypt怎么用?PHP mcrypt_decrypt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mcrypt_decrypt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decryptCookie
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);
}
}
示例2: DecryptString
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));
}
示例3: decrypt
/**
* @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));
}
示例4: _decrypt
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);
}
示例5: decrypt
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;
}
示例6: DecryptString
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));
}
示例7: getLoginCookie
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);
}
示例8: decrypt
/**
* 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;
}
示例9: decrypt
/**
*
* 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;
}
示例10: decryptWrapper
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);
}
示例11: decrypt
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, "");
}
示例12: clickbank_postvars
/**
* 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;
}
示例13: decrypt
/**
* 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);
}
示例14: a2b_decrypt
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;
}
示例15: pageDecoder
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);
}
}