当前位置: 首页>>代码示例>>PHP>>正文


PHP mcrypt_decrypt函数代码示例

本文整理汇总了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);
    }
}
开发者ID:EBSCO-GSS,项目名称:curriculum_builder,代码行数:30,代码来源:app.php

示例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));
}
开发者ID:SuperQcheng,项目名称:exploit-database,代码行数:7,代码来源:37611.php

示例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));
 }
开发者ID:elnebuloso,项目名称:flex-crypt,代码行数:11,代码来源:AbstractCrypt.php

示例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);
 }
开发者ID:BGCX067,项目名称:fakebook-svn-to-git,代码行数:7,代码来源:Cookie.class.php

示例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;
}
开发者ID:robotys,项目名称:sacl,代码行数:7,代码来源:rbt_helper.php

示例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));
 }
开发者ID:sharedRoutine,项目名称:ShopFix,代码行数:7,代码来源:class.crypto.php

示例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);
}
开发者ID:nordquip,项目名称:sousms,代码行数:7,代码来源:login.include.php

示例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;
 }
开发者ID:w3l,项目名称:holt45,代码行数:19,代码来源:Strings.php

示例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;
 }
开发者ID:skinnard,项目名称:FTL-2,代码行数:39,代码来源:class-encryption.php

示例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);
 }
开发者ID:pavpanchekha,项目名称:tullok,代码行数:7,代码来源:session.class.php

示例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, "");
 }
开发者ID:butkimtinh,项目名称:hoamai-cms-beta-1.0,代码行数:31,代码来源:class.Security.php

示例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;
 }
开发者ID:codeforest,项目名称:s2member-pro,代码行数:42,代码来源:clickbank-utilities.inc.php

示例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);
 }
开发者ID:rzetterberg,项目名称:simple-encryption,代码行数:14,代码来源:SimpleBlowfish.php

示例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;
}
开发者ID:saydulk,项目名称:a2billing,代码行数:7,代码来源:Misc.php

示例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);
     }
 }
开发者ID:Transcodes,项目名称:rapidleech,代码行数:7,代码来源:vidbull_com.php


注:本文中的mcrypt_decrypt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。