• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mcrypt_module_open函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中mcrypt_module_open函数的典型用法代码示例。如果您正苦于以下问题:PHP mcrypt_module_open函数的具体用法?PHP mcrypt_module_open怎么用?PHP mcrypt_module_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mcrypt_module_open函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  *
  * @param  string      $key        Secret encryption key.
  *                                 It's unsafe to store encryption key in memory, so no getter for key exists.
  * @param  string      $cipher     Cipher algorithm (one of the MCRYPT_ciphername constants)
  * @param  string      $mode       Mode of cipher algorithm (MCRYPT_MODE_modeabbr constants)
  * @param  string|bool $initVector Initial vector to fill algorithm blocks.
  *                                 TRUE generates a random initial vector.
  *                                 FALSE fills initial vector with zero bytes to not use it.
  * @throws Magento_Exception
  */
 public function __construct($key, $cipher = MCRYPT_BLOWFISH, $mode = MCRYPT_MODE_ECB, $initVector = false)
 {
     $this->_cipher = $cipher;
     $this->_mode = $mode;
     $this->_handle = mcrypt_module_open($cipher, '', $mode, '');
     try {
         $maxKeySize = mcrypt_enc_get_key_size($this->_handle);
         if (strlen($key) > $maxKeySize) {
             throw new Magento_Exception('Key must not exceed ' . $maxKeySize . ' bytes.');
         }
         $initVectorSize = mcrypt_enc_get_iv_size($this->_handle);
         if (true === $initVector) {
             /* Generate a random vector from human-readable characters */
             $abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
             $initVector = '';
             for ($i = 0; $i < $initVectorSize; $i++) {
                 $initVector .= $abc[rand(0, strlen($abc) - 1)];
             }
         } else {
             if (false === $initVector) {
                 /* Set vector to zero bytes to not use it */
                 $initVector = str_repeat("", $initVectorSize);
             } else {
                 if (!is_string($initVector) || strlen($initVector) != $initVectorSize) {
                     throw new Magento_Exception('Init vector must be a string of ' . $initVectorSize . ' bytes.');
                 }
             }
         }
         $this->_initVector = $initVector;
     } catch (Exception $e) {
         mcrypt_module_close($this->_handle);
         throw $e;
     }
     mcrypt_generic_init($this->_handle, $key, $initVector);
 }
开发者ID:natxetee,项目名称:magento2,代码行数:47,代码来源:Crypt.php


示例2: computeSign

 public function computeSign($sharedSecret)
 {
     if (!$this->isValid) {
         throw new Exception(__METHOD__ . ": Message was not validated.");
     }
     try {
         // ak mame zadany shared secret v hexa tvare tak ho prevedieme na 32 bytovy string
         if (strlen($sharedSecret) == 64) {
             $sharedSecret = pack('H*', $sharedSecret);
         }
         $base = $this->GetSignatureBase();
         $bytesHash = sha1($base, TRUE);
         // vezmeme prvych 16 bytov
         $bytesHash = substr($bytesHash, 0, 16);
         $aes = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
         $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($aes), MCRYPT_RAND);
         mcrypt_generic_init($aes, $sharedSecret, $iv);
         $bytesSign = mcrypt_generic($aes, $bytesHash);
         mcrypt_generic_deinit($aes);
         mcrypt_module_close($aes);
         $sign = strtoupper(bin2hex($bytesSign));
     } catch (Exception $e) {
         return FALSE;
     }
     return $sign;
 }
开发者ID:martinstrycek,项目名称:php-payments,代码行数:26,代码来源:EPaymentAes256SignedMessage.class.php


示例3: decrypt

 public function decrypt($msg, $k, $base64 = false)
 {
     if ($base64) {
         $msg = base64_decode($msg);
     }
     if (!($td = mcrypt_module_open('rijndael-256', '', 'ctr', ''))) {
         return false;
     }
     $iv = substr($msg, 0, 32);
     $mo = strlen($msg) - 32;
     $em = substr($msg, $mo);
     $msg = substr($msg, 32, strlen($msg) - 64);
     $mac = $this->pbkdf2($iv . $msg, $k, 1000, 32);
     if ($em !== $mac) {
         return false;
     }
     if (mcrypt_generic_init($td, $k, $iv) !== 0) {
         return false;
     }
     $msg = mdecrypt_generic($td, $msg);
     $msg = unserialize($msg);
     mcrypt_generic_deinit($td);
     mcrypt_module_close($td);
     return $msg;
 }
开发者ID:jasonwolf493,项目名称:ToolbeltJS,代码行数:25,代码来源:openbay.php


示例4: decrypt

 public function decrypt($data)
 {
     // if($this->input->ip_address() == '10.52.66.172') {
     // var_dump($data);
     // die;
     // }
     $key = "secret";
     $td = mcrypt_module_open(MCRYPT_DES, "", MCRYPT_MODE_ECB, "");
     $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
     mcrypt_generic_init($td, $key, $iv);
     // mcrypt_generic_deinit($td);
     // if($this->input->ip_address() == '10.52.66.172') {
     // var_dump($data);
     // die;
     // }
     $data = mdecrypt_generic($td, base64_decode($data));
     // if($this->input->ip_address() == '10.52.66.172') {
     // var_dump($data);
     // die;
     // }
     mcrypt_generic_deinit($td);
     if (substr($data, 0, 1) != '!') {
         return false;
     }
     $data = substr($data, 1, strlen($data) - 1);
     return unserialize($data);
 }
开发者ID:pollux1er,项目名称:dlawebdev2,代码行数:27,代码来源:albums.php


示例5: decrypt

 public function decrypt($encrypted, $appid = '')
 {
     try {
         $encrypted = base64_decode($encrypted);
         $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
         $iv = substr($this->key, 0, 16);
         mcrypt_generic_init($td, $this->key, $iv);
         $decrypted = mdecrypt_generic($td, $encrypted);
         mcrypt_generic_deinit($td);
         mcrypt_module_close($td);
     } catch (Exception $e) {
         throw new Exception($e->getMessage(), ErrorCode::$DecryptAESError);
     }
     try {
         $result = self::PKCS7Decode($decrypted);
         if (strlen($result) < 16) {
             throw new Exception('PKCS7Decode length less than 16', ErrorCode::$IllegalBuffer);
         }
         $content = substr($result, 16);
         $lenlist = unpack('N', substr($content, 0, 4));
         $xmlLen = $lenlist[1];
         $xmlData = substr($content, 4, $xmlLen);
         $fromId = substr($content, $xmlLen + 4);
     } catch (Exception $e) {
         throw new Exception($e->getMessage(), ErrorCode::$IllegalBuffer);
     }
     if ($fromId != $appid) {
         throw new Exception('Unvalidated Appid.', ErrorCode::$ValidateAppidError);
     } else {
         return $xmlData;
     }
 }
开发者ID:royalwang,项目名称:Pyramid,代码行数:32,代码来源:Prpcrypt.php


示例6: decryptNET3DES

function decryptNET3DES($key, $iv, $text)
{
    if (empty($text)) {
        return "";
    }
    $td = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_ECB, '');
    // 把key值补充完整,在PHP里面如果key值不够24位剩下的会自动补0,但是在.net中,会做一个循环把前面的值补充到后面补够24位,所以这里强制补前面的字符
    $key_add = 24 - strlen($key);
    $key .= substr($key, 0, $key_add);
    mcrypt_generic_init($td, $key, $iv);
    $decrypt_text = mdecrypt_generic($td, $text);
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);
    //去掉padding的尾巴,因为.net中默认的padding是PKCS7,而php中默认的padding是zero,所以在.net使用默认的情况下,要将php程序的padding重新设置
    $block = mcrypt_get_block_size('tripledes', 'ecb');
    $packing = ord($decrypt_text[strlen($decrypt_text) - 1]);
    if ($packing and $packing < $block) {
        for ($P = strlen($decrypt_text) - 1; $P >= strlen($decrypt_text) - $packing; $P--) {
            if (ord($decrypt_text[$P]) != $packing) {
                $packing = 0;
            }
        }
    }
    $decrypt_text = substr($decrypt_text, 0, strlen($decrypt_text) - $packing);
    return $decrypt_text;
}
开发者ID:empireghost,项目名称:netbeans-project,代码行数:26,代码来源:CryptoCustIdHelper.php


示例7: decrypt

 /**
  * 对密文进行解密
  * @param  string $encrypt 密文
  * @return string          明文
  */
 public function decrypt($encrypt)
 {
     //BASE64解码
     $encrypt = base64_decode($encrypt);
     //打开加密算法模块
     $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
     //初始化加密算法模块
     mcrypt_generic_init($td, $this->cyptKey, substr($this->cyptKey, 0, 16));
     //执行解密
     $decrypt = mdecrypt_generic($td, $encrypt);
     //去除PKCS7补位
     $decrypt = self::PKCS7Decode($decrypt, mcrypt_enc_get_key_size($td));
     //关闭加密算法模块
     mcrypt_generic_deinit($td);
     mcrypt_module_close($td);
     if (strlen($decrypt) < 16) {
         throw new \Exception("非法密文字符串!");
     }
     //去除随机字符串
     $decrypt = substr($decrypt, 16);
     //获取网络字节序
     $size = unpack("N", substr($decrypt, 0, 4));
     $size = $size[1];
     //APP_ID
     $appid = substr($decrypt, $size + 4);
     //验证APP_ID
     if ($appid !== $this->appId) {
         throw new \Exception("非法APP_ID!");
     }
     //明文内容
     $text = substr($decrypt, 4, $size);
     return $text;
 }
开发者ID:393197906,项目名称:hummingbird,代码行数:38,代码来源:WechatCrypt.class.php


示例8: ssl_encode

 function ssl_encode($data, $key = '')
 {
     // Use the Encrypt.php function get_key to encode the data.
     $key = $this->get_key($key);
     // Set a random salt
     $salt = substr(md5(mt_rand(), true), 8);
     $block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
     $pad = $block - strlen($data) % $block;
     $data = $data . str_repeat(chr($pad), $pad);
     // Setup encryption parameters
     $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_CBC, "");
     $key_len = mcrypt_enc_get_key_size($td);
     $iv_len = mcrypt_enc_get_iv_size($td);
     $total_len = $key_len + $iv_len;
     $salted = '';
     $dx = '';
     // Salt the key and iv
     while (strlen($salted) < $total_len) {
         $dx = md5($dx . $key . $salt, true);
         $salted .= $dx;
     }
     $key = substr($salted, 0, $key_len);
     $iv = substr($salted, $key_len, $iv_len);
     mcrypt_generic_init($td, $key, $iv);
     $encrypted_data = mcrypt_generic($td, $data);
     mcrypt_generic_deinit($td);
     mcrypt_module_close($td);
     return chunk_split(base64_encode('Salted__' . $salt . $encrypted_data), 32, "\n");
 }
开发者ID:kaptk2,项目名称:AirKey,代码行数:29,代码来源:MY_Encrypt.php


示例9: decrypt

 public function decrypt($encrypted, $is_id = false)
 {
     static $_map = array();
     if ($is_id) {
         $len = strlen($encrypted);
         $tmp = '';
         for ($i = 0; $i < $len; $i = $i + 2) {
             $tmp = $tmp . chr(hexdec($encrypted[$i] . $encrypted[$i + 1]));
         }
         $encrypted = $tmp;
     } else {
         $encrypted = base64_decode($encrypted);
     }
     $hashkey = md5($encrypted . $this->key);
     if (isset($_map[$hashkey])) {
         return $_map[$hashkey];
     }
     $key = str_pad($this->key, 24, '0');
     $td = mcrypt_module_open(MCRYPT_3DES, '', 'ecb', '');
     $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
     $ks = mcrypt_enc_get_key_size($td);
     @mcrypt_generic_init($td, $key, $iv);
     $decrypted = mdecrypt_generic($td, $encrypted);
     mcrypt_generic_deinit($td);
     mcrypt_module_close($td);
     $y = $this->pkcs5_unpad($decrypted);
     if ($is_id) {
         $y = base_convert($y, 36, 10);
     }
     $_map[$hashkey] = $y;
     return $y;
 }
开发者ID:lanma121,项目名称:superPrize,代码行数:32,代码来源:Encty.php


示例10: decrypt

 static function decrypt($input, $base64 = true)
 {
     if (!$input || !strlen($input) > 0) {
         return null;
     }
     if (!($td = mcrypt_module_open('rijndael-256', '', 'ctr', ''))) {
         return null;
     }
     if ($base64) {
         $content = base64_decode($input);
     } else {
         $content = $input;
     }
     $iv = substr($content, 0, 32);
     $extract = substr($content, strlen($content) - 32);
     $content = substr($content, 32, strlen($content) - 64);
     $mac = self::pbkdf2($iv . $content, MSettings::$c_key, 1000, 32);
     if ($extract !== $mac) {
         return null;
     }
     if (mcrypt_generic_init($td, MSettings::$c_key, $iv) !== 0) {
         return null;
     }
     $content = mdecrypt_generic($td, $content);
     $content = unserialize($content);
     mcrypt_generic_deinit($td);
     mcrypt_module_close($td);
     return $content;
 }
开发者ID:adncentral,项目名称:mapi-geoCMS,代码行数:29,代码来源:mlib.crypt.php


示例11: decrypt

 public function decrypt($encrypted, $appid)
 {
     try {
         $ciphertext_dec = base64_decode($encrypted);
         $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
         $iv = substr($this->key, 0, 16);
         mcrypt_generic_init($module, $this->key, $iv);
         $decrypted = mdecrypt_generic($module, $ciphertext_dec);
         mcrypt_generic_deinit($module);
         mcrypt_module_close($module);
     } catch (Exception $e) {
         return array(ErrorCode::$DecryptAESError, NULL);
     }
     try {
         $pkc_encoder = new PKCS7Encoder();
         $result = $pkc_encoder->decode($decrypted);
         if (strlen($result) < 16) {
             return '';
         }
         $content = substr($result, 16, strlen($result));
         $len_list = unpack('N', substr($content, 0, 4));
         $xml_len = $len_list[1];
         $xml_content = substr($content, 4, $xml_len);
         $from_appid = substr($content, $xml_len + 4);
     } catch (Exception $e) {
         print $e;
         return array(ErrorCode::$IllegalBuffer, NULL);
     }
     if ($from_appid != $appid) {
         return array(ErrorCode::$ValidateAppidError, NULL);
     }
     return array(0, $xml_content);
 }
开发者ID:fkssei,项目名称:pigcms10,代码行数:33,代码来源:pkcs7Encoder.php


示例12: decrypt

 /**
  * Decryption of data
  *
  * @param string      $data	Data to be decrypted
  * @param bool|string $key	Key, if not specified - system key will be used
  *
  * @return bool|mixed
  */
 function decrypt($data, $key = false)
 {
     if (!$this->encrypt_support) {
         return $data;
     }
     if (!is_resource($this->td)) {
         $this->td = mcrypt_module_open(MCRYPT_BLOWFISH, '', 'cbc', '');
         $this->key = mb_substr($this->key, 0, mcrypt_enc_get_key_size($this->td));
         $this->iv = mb_substr(md5($this->iv), 0, mcrypt_enc_get_iv_size($this->td));
     }
     if ($key === false) {
         $key = $this->key;
     } else {
         $key = mb_substr(md5($this->key) . md5($key), 0, mcrypt_enc_get_key_size($this->td));
     }
     mcrypt_generic_init($this->td, $key, $this->iv);
     errors_off();
     $decrypted = @unserialize(mdecrypt_generic($this->td, $data));
     errors_on();
     mcrypt_generic_deinit($this->td);
     if (is_array($decrypted) && $decrypted['key'] == $key) {
         return $decrypted['data'];
     } else {
         return false;
     }
 }
开发者ID:hypnomez,项目名称:opir.org,代码行数:34,代码来源:Encryption.php


示例13: __construct

 public function __construct($key = '', $algorithm = MCRYPT_DES, $mode = MCRYPT_MODE_CBC)
 {
     if (!empty($key)) {
         $this->key = $key;
     }
     $this->encrypter = mcrypt_module_open($algorithm, '', $mode, '');
 }
开发者ID:foolin,项目名称:myblog_article_code,代码行数:7,代码来源:des.php


示例14: decrypt

 public function decrypt($encrypted, $corpid)
 {
     try {
         $ciphertext_dec = base64_decode($encrypted);
         $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
         $iv = substr($this->key, 0, 16);
         mcrypt_generic_init($module, $this->key, $iv);
         $decrypted = mdecrypt_generic($module, $ciphertext_dec);
         mcrypt_generic_deinit($module);
         mcrypt_module_close($module);
     } catch (Exception $e) {
         return array(ErrorCode::$DecryptAESError, null);
     }
     try {
         //去除补位字符
         $pkc_encoder = new PKCS7Encoder();
         $result = $pkc_encoder->decode($decrypted);
         //去除16位随机字符串,网络字节序和AppId
         if (strlen($result) < 16) {
             return "";
         }
         $content = substr($result, 16, strlen($result));
         $len_list = unpack("N", substr($content, 0, 4));
         $xml_len = $len_list[1];
         $xml_content = substr($content, 4, $xml_len);
         $from_corpid = substr($content, $xml_len + 4);
     } catch (Exception $e) {
         print $e;
         return array(ErrorCode::$DecryptAESError, null);
     }
     if ($from_corpid != $corpid) {
         return array(ErrorCode::$ValidateSuiteKeyError, null);
     }
     return array(0, $xml_content);
 }
开发者ID:vincent067,项目名称:openapi-demo-php,代码行数:35,代码来源:pkcs7Encoder.php


示例15: decrypt

 private function decrypt($input, $base64 = false)
 {
     if ($this->key == '') {
         return false;
     }
     if ($base64) {
         $input = base64_decode($input);
     }
     if (!($td = mcrypt_module_open('rijndael-256', '', 'ctr', ''))) {
         return false;
     }
     $iv = substr($input, 0, 32);
     $mace = substr($input, strlen($input) - 32);
     $input = substr($input, 32, strlen($input) - 64);
     $macd = $this->pbkdf2($iv . $input, $this->key, 1000, 32);
     if ($mace !== $macd) {
         return false;
     }
     if (mcrypt_generic_init($td, $this->key, $iv) !== 0) {
         return false;
     }
     $decrypted_data = mdecrypt_generic($td, $input);
     $decrypted_data = unserialize($decrypted_data);
     mcrypt_generic_deinit($td);
     mcrypt_module_close($td);
     return $decrypted_data;
 }
开发者ID:adrianha,项目名称:Rafa-Server,代码行数:27,代码来源:Res.php


示例16: authenticate

 public function authenticate(array $credentials)
 {
     $mcrypt = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, '');
     $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($mcrypt), MCRYPT_DEV_RANDOM);
     mcrypt_generic_init($mcrypt, $this->cryptPassword, $iv);
     $url = $this->getUrl($credentials[self::USERNAME], $credentials[self::PASSWORD], $mcrypt, $iv);
     try {
         $res = $this->httpClient->get($url)->send();
     } catch (\Guzzle\Http\Exception\ClientErrorResponseException $e) {
         if ($e->getResponse()->getStatusCode() === 403) {
             throw new \Nette\Security\AuthenticationException("User '{$credentials[self::USERNAME]}' not found.", self::INVALID_CREDENTIAL);
         } elseif ($e->getResponse()->getStatusCode() === 404) {
             throw new \Nette\Security\AuthenticationException("Invalid password.", self::IDENTITY_NOT_FOUND);
         } else {
             throw $e;
         }
     }
     $responseBody = trim(mdecrypt_generic($mcrypt, $res->getBody(TRUE)));
     $apiData = Json::decode($responseBody);
     $user = $this->db->table('users')->where('id = ?', $apiData->id)->fetch();
     $registered = new \DateTimeImmutable($apiData->registered->date, new \DateTimeZone($apiData->registered->timezone));
     $userData = array('username' => $credentials[self::USERNAME], 'password' => $this->calculateAddonsPortalPasswordHash($credentials[self::PASSWORD]), 'email' => $apiData->email, 'realname' => $apiData->realname, 'url' => $apiData->url, 'signature' => $apiData->signature, 'language' => $apiData->language, 'num_posts' => $apiData->num_posts, 'apiToken' => $apiData->apiToken, 'registered' => $registered->getTimestamp());
     if (!$user) {
         $userData['id'] = $apiData->id;
         $userData['group_id'] = 4;
         $this->db->table('users')->insert($userData);
         $user = $this->db->table('users')->where('username = ?', $credentials[self::USERNAME])->fetch();
     } else {
         $user->update($userData);
     }
     return $this->createIdentity($user);
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:32,代码来源:NetteOrgAuthenticator.php


示例17: __construct

 private function __construct()
 {
     if (!function_exists('mcrypt_module_open')) {
         throw new Hayate_Exception(sprintf(_('%s: mcrypt extension is missing.'), __CLASS__));
     }
     switch (self::ALGO) {
         case 'aes':
             $algo = MCRYPT_RIJNDAEL_256;
             break;
         case 'tripledes':
             $algo = MCRYPT_TRIPLEDES;
             break;
         case 'blowfish':
             $algo = MCRYPT_BLOWFISH;
             break;
         default:
             throw new Hayate_Exception(sprintf(_('%s is not supported, please use "aes", "tripledes" or "blowfish"'), self::ALGO));
     }
     // initialize mcrypt
     $this->mcrypt = mcrypt_module_open($algo, '', MCRYPT_MODE_CBC, '');
     // calculate IV size
     $this->ivsize = mcrypt_enc_get_iv_size($this->mcrypt);
     // calculate key max key length
     $this->maxKeysize = mcrypt_enc_get_key_size($this->mcrypt);
     $config = Hayate_Config::getInstance();
     if ($config->get('core.secret_key', false)) {
         $this->setKey($config->core->secret_key);
     }
 }
开发者ID:hayate,项目名称:hayate,代码行数:29,代码来源:Crypto.php


示例18: salt

 public function salt()
 {
     $td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, "", MCRYPT_MODE_CBC, "");
     $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_URANDOM);
     $hash = hash("Whirlpool", $iv);
     return $hash;
 }
开发者ID:cozylife,项目名称:tht-reworked,代码行数:7,代码来源:class_crypto.php


示例19: _getComplete

 /**
  * _getComplete
  *
  * method is prepare complete xml data call from callback url page.
  *
  * @param Dahius_VirtualPos_Request $request
  * @return string 
  */
 protected function _getComplete($request)
 {
     $response = new Dahius_VirtualPos_Response();
     $response->createdOn = time();
     $response->createdBy = $this->_name;
     // Check 3D Values
     $merchantPack = $request->threeDResponse["MerchantPacket"];
     $bankPack = $request->threeDResponse["BankPacket"];
     $sign = $request->threeDResponse["Sign"];
     $hash = strtoupper(md5($merchantPack . $bankPack . $this->_parameters->getPath("merchant_key")));
     if (strcmp($hash, $sign) != 0) {
         $response->code = -4;
         $response->message = "Package Not Matched";
         return $response;
     }
     // Get MD Status...
     $block = mcrypt_get_block_size(MCRYPT_TripleDES, MCRYPT_MODE_CBC);
     $tdes = mcrypt_module_open(MCRYPT_TripleDES, '', MCRYPT_MODE_CBC, '');
     $key_size = mcrypt_enc_get_key_size($tdes);
     $merchant_info = $this->_deCrypt($merchantPack, $this->_parameters->getPath("merchant_key"), $block, $tdes, $key_size);
     mcrypt_generic_deinit($tdes);
     mcrypt_module_close($tdes);
     list($mid, $tid, $amount, $instant, $xid, $tp, $tpo, $webURL, $ip, $port, $txStatus, $mdStatus, $errMsg, $transactionTime, $currency) = explode(";", $merchant_info);
     if (!in_array($mdStatus, $this->_parameters->getPath("valid_md_status"))) {
         $response->code = -3;
         $response->message = "mdStatus({$request->threeDResponse["mdStatus"]}) Not Valid";
         return $response;
     }
     $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-9\"?>\n                <posnetRequest>\n                    <mid>{$this->_parameters->getPath("mid")}</mid>\n                    <tid>{$this->_parameters->getPath("tid")}</tid>\n                    <username>{$this->_parameters->getPath("username")}</username>\n                    <password>{$this->_parameters->getPath("password")}</password>\n                    <oosTran>\n                        <bank>{$bankPack}</bank>\n                        <wpAmount>0</wpAmount>\n                    </oosTran>\n                </posnetRequest>";
     return "xmldata={$xml}";
 }
开发者ID:hisef,项目名称:vpos4php,代码行数:39,代码来源:Posnet.php


示例20: getEncryptionDescriptor

 /**
  * Generate encryption descriptor
  *
  * @return resource
  */
 private function getEncryptionDescriptor()
 {
     if (is_null($this->encryptionDescriptor)) {
         $this->encryptionDescriptor = mcrypt_module_open(MCRYPT_TRIPLEDES, '', MCRYPT_MODE_CBC, '');
     }
     return $this->encryptionDescriptor;
 }
开发者ID:testinaweb,项目名称:dynamic-crypto,代码行数:12,代码来源:MCryptTrait.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mcrypt_module_self_test函数代码示例发布时间:2022-05-15
下一篇:
PHP mcrypt_module_get_algo_key_size函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap