本文整理汇总了PHP中mcrypt_generic_deinit函数的典型用法代码示例。如果您正苦于以下问题:PHP mcrypt_generic_deinit函数的具体用法?PHP mcrypt_generic_deinit怎么用?PHP mcrypt_generic_deinit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mcrypt_generic_deinit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例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($text)
{
mcrypt_generic_init($this->td, $this->key, $this->iv);
$decrypted = mdecrypt_generic($this->td, $text);
mcrypt_generic_deinit($this->td);
return $decrypted;
}
开发者ID:HyuchiaDiego,项目名称:Kirino,代码行数:7,代码来源:Crypt.php
示例4: decrypt
public static function decrypt($data)
{
$crypteddata = base64_decode($data);
// HMAC is the last 32 bytes
$givenhmac = substr($crypteddata, -32);
// now we check that the payload actually matches the HMAC
$crypteddata = substr($crypteddata, 0, -32);
// data without the HMAC
$knownhmac = hash_hmac('sha256', $crypteddata, Config::$a['crypto']['seed'], true);
// compare the HMACs in a side-channel safe way
if (!self::constantTimeCompare($knownhmac, $givenhmac)) {
return '';
}
// the IV is the next 32 bytes, the actual size of the IV is not really
// important since we get it dynamically
$ivlength = mcrypt_get_iv_size('rijndael-256', 'ctr');
$iv = substr($crypteddata, -$ivlength);
// everything else is the encrypted payload
$crypteddata = substr($crypteddata, 0, -$ivlength);
// pass in the IV so that decryption can work
$crypt = self::initCrypt($iv);
$ret = mdecrypt_generic($crypt['mod'], $crypteddata);
mcrypt_generic_deinit($crypt['mod']);
return $ret;
}
开发者ID:0x9ae76c,项目名称:website,代码行数:25,代码来源:Crypto.php
示例5: enkripsi_plain2
function enkripsi_plain2($algoritma, $mode, $secretkey, $fileplain)
{
/* Membuka Modul untuk memilih Algoritma & Mode Operasi */
$td = mcrypt_module_open($algoritma, '', $mode, '');
/* Inisialisasi IV dan Menentukan panjang kunci yang digunakan*/
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$ks = mcrypt_enc_get_key_size($td);
/* Menghasilkan Kunci */
$key = $secretkey;
//echo "kuncinya : ". $key. "<br>";
/* Inisialisasi */
mcrypt_generic_init($td, $key, $iv);
/* Enkripsi Data, dimana hasil enkripsi harus di encode dengan base64.\
Hal ini dikarenakan web browser tidak dapat membaca karakter-karakter\
ASCII dalam bentuk simbol-simbol */
$buffer = $fileplain;
$encrypted = mcrypt_generic($td, $buffer);
$encrypted1 = base64_encode($iv) . ";" . base64_encode($encrypted);
$encrypted2 = base64_encode($encrypted1);
$filecipher = $encrypted2;
/* Menghentikan proses enkripsi dan menutup modul */
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return $filecipher;
}
开发者ID:kartikads,项目名称:ch,代码行数:25,代码来源:mcrypt_function.php
示例6: decrypt
public static function decrypt($string, $key = null, $salt = null, $iv = null)
{
$config = ConfigManager::getConfig('Crypto', 'AES256')->AuxConfig;
if ($key === null) {
$key = $config->key;
}
if ($salt === null) {
$salt = $config->salt;
}
if ($iv === null) {
$iv = $config->iv;
}
$td = mcrypt_module_open('rijndael-128', '', MCRYPT_MODE_CBC, '');
$ks = mcrypt_enc_get_key_size($td);
$bs = mcrypt_enc_get_block_size($td);
$iv = substr(hash("sha256", $iv), 0, $bs);
// Create key
$key = Crypto::pbkdf2("sha512", $key, $salt, $config->pbkdfRounds, $ks);
// Initialize encryption module for decryption
mcrypt_generic_init($td, $key, $iv);
$decryptedString = "";
// Decrypt encrypted string
try {
if (ctype_xdigit($string)) {
$decryptedString = trim(mdecrypt_generic($td, pack("H*", $string)));
}
} catch (ErrorException $e) {
}
// Terminate decryption handle and close module
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
// Show string
return $decryptedString;
}
开发者ID:Welvin,项目名称:stingle,代码行数:34,代码来源:AES256.class.php
示例7: encrypt
public function encrypt($string)
{
mcrypt_generic_init($this->cipher, $this->key, $this->iv);
$cipherText = mcrypt_generic($this->cipher, $string);
mcrypt_generic_deinit($this->cipher);
return $cipherText;
}
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:7,代码来源:AesCbcMcrypt.class.php
示例8: decrypt
public function decrypt($data)
{
mcrypt_generic_init($this->module, $this->key, $this->iv);
$ret = mdecrypt_generic($this->module, $data);
mcrypt_generic_deinit($this->module);
return rtrim($ret, "");
}
开发者ID:Ronmi,项目名称:fruit-cryptokit,代码行数:7,代码来源:Mcrypt.php
示例9: 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,代码来源:article.php
示例10: decrypt
public static function decrypt($varValue, $clesCryptage = null)
{
self::initialize();
// Recursively decrypt arrays
if (is_array($varValue)) {
foreach ($varValue as $k => $v) {
$varValue[$k] = self::decrypt(urldecode($v));
}
return $varValue;
} elseif ($varValue == '') {
return '';
}
$varValue = base64_decode($varValue);
$ivsize = mcrypt_enc_get_iv_size(self::$resTd);
$iv = substr($varValue, 0, $ivsize);
$varValue = substr($varValue, $ivsize);
if ($varValue == '') {
return '';
}
if ($clesCryptage === null) {
$clesCryptage = self::$clesCryptage;
}
mcrypt_generic_init(self::$resTd, md5($clesCryptage), $iv);
$strDecrypted = mdecrypt_generic(self::$resTd, $varValue);
mcrypt_generic_deinit(self::$resTd);
if (strpos($strDecrypted, "%") !== false) {
return urldecode($strDecrypted);
} else {
return $strDecrypted;
}
}
开发者ID:SylvainSimon,项目名称:Metinify,代码行数:31,代码来源:Encryption.php
示例11: 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
示例12: _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
示例13: 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
示例14: 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
示例15: decrypt
public function decrypt($ciphertext)
{
mcrypt_generic_init($this->encrypter, $this->key, substr($this->key, 0, 16));
$origData = mdecrypt_generic($this->encrypter, $ciphertext);
mcrypt_generic_deinit($this->encrypter);
return pkcs5unPadding($origData);
}
开发者ID:victor-u,项目名称:encryption-aes,代码行数:7,代码来源:aescrypter.php
示例16: get_sso_token
/**
* @param string $api_key API ключ UserEcho
* @param string $project_key Ключ UserEcho
* @param array $user_info
*
* @return SSO KEY
*/
public static function get_sso_token($api_key, $project_key, $user_info)
{
$sso_key = '';
if ($uid = get_uid(false)) {
$user = new users();
$user->GetUserByUID($uid);
$iv = str_shuffle('memoKomo1234QWER');
$message = array('guid' => $uid, 'expires_date' => gmdate('Y-m-d H:i:s', time() + 86400), 'display_name' => $user->login, 'email' => $user->email, 'locale' => 'ru', 'verified_email' => true);
// key hash, length = 16
$key_hash = substr(hash('sha1', $api_key . $project_key, true), 0, 16);
$message_json = json_encode(encodeCharset('CP1251', 'UTF-8', $message));
// double XOR first block message_json
for ($i = 0; $i < 16; ++$i) {
$message_json[$i] = $message_json[$i] ^ $iv[$i];
}
// fill tail of message_json by bytes equaled count empty bytes (to 16)
$pad = 16 - strlen($message_json) % 16;
$message_json = $message_json . str_repeat(chr($pad), $pad);
// encode json
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
mcrypt_generic_init($cipher, $key_hash, $iv);
$encrypted_bytes = mcrypt_generic($cipher, $message_json);
mcrypt_generic_deinit($cipher);
// encode bytes to url safe string
$sso_key = urlencode(base64_encode($encrypted_bytes));
}
return $sso_key;
}
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:35,代码来源:userecho.php
示例17: computeSign
public function computeSign($sharedSecret)
{
if (!$this->isValid) {
throw new Exception(__METHOD__ . ": Message was not validated.");
}
try {
$bytesHash = sha1($this->GetSignatureBase(), true);
$sharedSecret = pack('H*', $sharedSecret);
// uprava pre PHP < 5.0
if (strlen($bytesHash) != 20) {
$bytes = "";
for ($i = 0; $i < strlen($bytesHash); $i += 2) {
$bytes .= chr(hexdec(substr($str, $i, 2)));
}
$bytesHash = $bytes;
}
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_ECB, "");
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($cipher), MCRYPT_RAND);
mcrypt_generic_init($cipher, $sharedSecret, $iv);
$text = $this->pad(substr($bytesHash, 0, 16), mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB));
$bytesSign = mcrypt_generic($cipher, $text);
mcrypt_generic_deinit($cipher);
mcrypt_module_close($cipher);
$sign = substr(strtoupper(bin2hex($bytesSign)), 0, 32);
} catch (Exception $e) {
return false;
}
return $sign;
}
开发者ID:martinstrycek,项目名称:php-payments,代码行数:29,代码来源:EPaymentAesSignedMessage.class.php
示例18: 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
示例19: to_string
/**
* Outputs a Multipass token for the array provided. The array is a freeform
* array that should conform to the requirements set forth by TenderApp with
* regards to required and recommended values.
*
* It is not necessary to pass in the expiration date. This library will
* generate that for you automatically.
*
* @param data An associative array containing the data to be encoded.
* @return An encoded multipass token.
*/
function to_string($data)
{
require_once "JSON.php";
$json = new Services_JSON();
// error checking for key names
// unique_id, email required
$data['expires'] = date('D M d H:i:s e Y', time() + 60 * $this->expires);
$sso = $json->encode($data);
$salted = $this->site_key . $this->api_key;
$hash = hash('sha1', $salted, true);
$saltedHash = substr($hash, 0, 16);
$iv = "OpenSSL for PHP!";
for ($i = 0; $i < 16; $i++) {
$sso[$i] = $sso[$i] ^ $iv[$i];
}
$pad = 16 - strlen($sso) % 16;
$sso = $sso . str_repeat(chr($pad), $pad);
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
mcrypt_generic_init($cipher, $saltedHash, $iv);
$enc = mcrypt_generic($cipher, $sso);
mcrypt_generic_deinit($cipher);
$b64 = base64_encode($enc);
$b64 = preg_replace('/\\n/', '', $b64);
$b64 = preg_replace('/\\=*$/', '', $b64);
$b64 = preg_replace('/\\+/', '-', $b64);
$b64 = preg_replace('/\\//', '_', $b64);
return $b64;
}
开发者ID:byrnereese,项目名称:php-Tender-Multipass,代码行数:39,代码来源:TenderMultipass.php
示例20: 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
注:本文中的mcrypt_generic_deinit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论