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


PHP mcrypt_enc_get_modes_name函数代码示例

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


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

示例1: _mcrypt_decrypt

 /**
  * Decrypt via MCrypt
  *
  * @param	string	$data	Encrypted data
  * @param	array	$params	Input parameters
  * @return	string
  */
 protected function _mcrypt_decrypt($data, $params)
 {
     if (!is_resource($params['handle'])) {
         return FALSE;
     }
     // The greater-than-1 comparison is mostly a work-around for a bug,
     // where 1 is returned for ARCFour instead of 0.
     if (($iv_size = mcrypt_enc_get_iv_size($params['handle'])) > 1) {
         if (mcrypt_enc_get_modes_name($params['handle']) !== 'ECB') {
             $iv = self::substr($data, 0, $iv_size);
             $data = self::substr($data, $iv_size);
         } else {
             // MCrypt is dumb and this is ignored, only size matters
             $iv = str_repeat("", $iv_size);
         }
     } else {
         $iv = NULL;
     }
     if (mcrypt_generic_init($params['handle'], $params['key'], $iv) < 0) {
         if ($params['handle'] !== $this->_handle) {
             mcrypt_module_close($params['handle']);
         }
         return FALSE;
     }
     $data = mdecrypt_generic($params['handle'], $data);
     // Remove PKCS#7 padding, if necessary
     if (in_array(strtolower(mcrypt_enc_get_modes_name($params['handle'])), array('cbc', 'ecb'), TRUE)) {
         $data = self::substr($data, 0, -ord($data[self::strlen($data) - 1]));
     }
     mcrypt_generic_deinit($params['handle']);
     if ($params['handle'] !== $this->_handle) {
         mcrypt_module_close($params['handle']);
     }
     return $data;
 }
开发者ID:SaiAshirwadInformatia,项目名称:TaskTracker,代码行数:42,代码来源:Encryption.php

示例2: _mcrypt_decrypt

 /**
  * Decrypt via MCrypt
  *
  * @param	string	$data	Encrypted data
  * @param	array	$params	Input parameters
  * @return	string
  */
 protected function _mcrypt_decrypt($data, $params)
 {
     if (!is_resource($params['handle'])) {
         return FALSE;
     } elseif (!isset($params['iv'])) {
         // The greater-than-1 comparison is mostly a work-around for a bug,
         // where 1 is returned for ARCFour instead of 0.
         if (($iv_size = mcrypt_enc_get_iv_size($params['handle'])) > 1) {
             if (mcrypt_enc_get_modes_name($params['handle']) !== 'ECB') {
                 $params['iv'] = substr($data, 0, $iv_size);
                 $data = substr($data, $iv_size);
             } else {
                 // MCrypt is dumb and this is ignored, only size matters
                 $params['iv'] = str_repeat("", $iv_size);
             }
         } else {
             $params['iv'] = NULL;
         }
     }
     // CAST-128 compatibility (http://tools.ietf.org/rfc/rfc2144.txt)
     //
     // RFC2144 says that keys shorter than 16 bytes are to be padded with
     // zero bytes to 16 bytes, but (surprise) MCrypt doesn't do that.
     if ($params['cipher'] === 'cast-128' && ($kl = strlen($params['key'])) < 16) {
         $params['key'] .= str_repeat("", 16 - $kl);
     }
     if (mcrypt_generic_init($params['handle'], $params['key'], $params['iv']) < 0) {
         if ($params['handle'] !== $this->_handle) {
             mcrypt_module_close($params['handle']);
         }
         return FALSE;
     }
     $data = mdecrypt_generic($params['handle'], $data);
     // Remove PKCS#7 padding, if necessary
     if (in_array(strtolower(mcrypt_enc_get_modes_name($params['handle'])), array('cbc', 'ecb'), TRUE)) {
         $data = substr($data, 0, -ord($data[strlen($data) - 1]));
     }
     mcrypt_generic_deinit($params['handle']);
     if ($params['handle'] !== $this->_handle) {
         mcrypt_module_close($params['handle']);
     }
     return $data;
 }
开发者ID:jayalfredprufrock,项目名称:codeigniter-boilerplate,代码行数:50,代码来源:Encryption.php

示例3: mcrypt_module_open

<?php

$td = mcrypt_module_open('rijndael-128', '', MCRYPT_MODE_ECB, '');
echo mcrypt_enc_get_modes_name($td) . "\n";
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
echo mcrypt_enc_get_modes_name($td) . "\n";
$td = mcrypt_module_open(MCRYPT_WAKE, '', MCRYPT_MODE_STREAM, '');
echo mcrypt_enc_get_modes_name($td) . "\n";
$td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_OFB, '');
echo mcrypt_enc_get_modes_name($td) . "\n";
$td = mcrypt_module_open('des', '', 'ecb', '');
echo mcrypt_enc_get_modes_name($td) . "\n";
$td = mcrypt_module_open('des', '', 'cbc', '');
echo mcrypt_enc_get_modes_name($td) . "\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:14,代码来源:mcrypt_enc_get_mode_name.php

示例4: mcrypt_ofb

$CC = "4007000000027";
$encrypted = mcrypt_ofb(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $CC, MCRYPT_ENCRYPT, substr($key, 32, 16));
$decrypted = mcrypt_ofb(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $encrypted, MCRYPT_DECRYPT, substr($key, 32, 16));
VERIFY($encrypted !== $decrypted);
VS($decrypted, $CC);
//////////////////////////////////////////////////////////////////////
VS(mcrypt_get_block_size("tripledes", "ecb"), 8);
VS(mcrypt_get_cipher_name(MCRYPT_TRIPLEDES), "3DES");
VS(mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB), 16);
VS(mcrypt_get_iv_size("des", "ecb"), 8);
VS(mcrypt_get_key_size("tripledes", "ecb"), 24);
$td = mcrypt_module_open("cast-256", "", "cfb", "");
VS(mcrypt_enc_get_algorithms_name($td), "CAST-256");
$td = mcrypt_module_open("tripledes", "", "ecb", "");
VS(mcrypt_enc_get_block_size($td), 8);
$td = mcrypt_module_open("cast-256", "", "cfb", "");
VS(mcrypt_enc_get_iv_size($td), 16);
$td = mcrypt_module_open("tripledes", "", "ecb", "");
VS(mcrypt_enc_get_key_size($td), 24);
$td = mcrypt_module_open("cast-256", "", "cfb", "");
VS(mcrypt_enc_get_modes_name($td), "CFB");
$td = mcrypt_module_open("rijndael-256", "", "ecb", "");
VS(mcrypt_enc_get_supported_key_sizes($td), array(16, 24, 32));
$td = mcrypt_module_open("tripledes", "", "ecb", "");
VS(mcrypt_enc_is_block_algorithm_mode($td), true);
$td = mcrypt_module_open("tripledes", "", "ecb", "");
VS(mcrypt_enc_is_block_algorithm($td), true);
$td = mcrypt_module_open("tripledes", "", "ecb", "");
VS(mcrypt_enc_is_block_mode($td), true);
$td = mcrypt_module_open("tripledes", "", "ecb", "");
VS(mcrypt_enc_self_test($td), 0);
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ext_mcrypt.php

示例5: mcrypt_module_open

<?php

$td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
mcrypt_generic_init($td, '', 'a');
var_dump(mcrypt_enc_get_algorithms_name($td));
var_dump(mcrypt_enc_get_block_size($td));
var_dump(mcrypt_enc_get_iv_size($td));
var_dump(mcrypt_enc_get_key_size($td));
var_dump(mcrypt_enc_get_modes_name($td));
var_dump(mcrypt_enc_get_supported_key_sizes($td));
var_dump(mcrypt_enc_self_test($td));
var_dump(mcrypt_generic_init($td, '', 'a'));
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:ext_mcrypt_return_types.php


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