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

PHP mcrypt_get_iv_size函数代码示例

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

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



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

示例1: decodePassword

 public static function decodePassword($sPassword, $sSalt)
 {
     if (function_exists('mcrypt_encrypt') && function_exists('mcrypt_create_iv') && function_exists('mcrypt_get_iv_size') && defined('MCRYPT_RIJNDAEL_256') && defined('MCRYPT_MODE_ECB') && defined('MCRYPT_RAND')) {
         return @base64_decode(trim(@mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($sSalt), base64_decode(trim($sPassword)), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
     }
     return @base64_decode(trim($sPassword));
 }
开发者ID:hiaio-platform-medical,项目名称:rainloop-webmail,代码行数:7,代码来源:RainLoopHelper.php


示例2: __construct

 /**
  * Loads encryption configuration and validates the data.
  *
  * @param   array|string      custom configuration or config group name
  * @throws  Kohana_Exception
  */
 public function __construct($config = FALSE)
 {
     if (!defined('MCRYPT_ENCRYPT')) {
         throw new Kohana_Exception('encrypt.requires_mcrypt');
     }
     if (is_string($config)) {
         $name = $config;
         // Test the config group name
         if (($config = Kohana::config('encryption.' . $config)) === NULL) {
             throw new Kohana_Exception('encrypt.undefined_group', $name);
         }
     }
     if (is_array($config)) {
         // Append the default configuration options
         $config += Kohana::config('encryption.default');
     } else {
         // Load the default group
         $config = Kohana::config('encryption.default');
     }
     if (empty($config['key'])) {
         throw new Kohana_Exception('encrypt.no_encryption_key');
     }
     // Find the max length of the key, based on cipher and mode
     $size = mcrypt_get_key_size($config['cipher'], $config['mode']);
     if (strlen($config['key']) > $size) {
         // Shorten the key to the maximum size
         $config['key'] = substr($config['key'], 0, $size);
     }
     // Find the initialization vector size
     $config['iv_size'] = mcrypt_get_iv_size($config['cipher'], $config['mode']);
     // Cache the config in the object
     $this->config = $config;
     Kohana::log('debug', 'Encrypt Library initialized');
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:40,代码来源:Encrypt.php


示例3: __construct

 public function __construct($_key = '', $_bit = 128, $_type = 'ecb', $_use_base64 = true)
 {
     // 加密字节
     if (192 === $_bit) {
         $this->_bit = MCRYPT_RIJNDAEL_192;
     } elseif (128 === $_bit) {
         $this->_bit = MCRYPT_RIJNDAEL_128;
     } else {
         $this->_bit = MCRYPT_RIJNDAEL_256;
     }
     // 加密方法
     if ('cfb' === $_type) {
         $this->_type = MCRYPT_MODE_CFB;
     } elseif ('cbc' === $_type) {
         $this->_type = MCRYPT_MODE_CBC;
     } elseif ('nofb' === $_type) {
         $this->_type = MCRYPT_MODE_NOFB;
     } elseif ('ofb' === $_type) {
         $this->_type = MCRYPT_MODE_OFB;
     } elseif ('stream' === $_type) {
         $this->_type = MCRYPT_MODE_STREAM;
     } else {
         $this->_type = MCRYPT_MODE_ECB;
     }
     // 密钥
     if (!empty($_key)) {
         $this->_key = $_key;
     }
     // 是否使用base64
     $this->_use_base64 = $_use_base64;
     $this->_iv_size = mcrypt_get_iv_size($this->_bit, $this->_type);
     $this->_iv = mcrypt_create_iv($this->_iv_size, MCRYPT_RAND);
 }
开发者ID:676496871,项目名称:Demo,代码行数:33,代码来源:Aes.php


示例4: generateSettingsFile

 /**
  * Generate settings file
  */
 public function generateSettingsFile($database_server, $database_login, $database_password, $database_name, $database_prefix, $database_engine)
 {
     // Check permissions for settings file
     if (file_exists(_PS_ROOT_DIR_ . '/' . self::SETTINGS_FILE) && !is_writable(_PS_ROOT_DIR_ . '/' . self::SETTINGS_FILE)) {
         $this->setError($this->language->l('%s file is not writable (check permissions)', self::SETTINGS_FILE));
         return false;
     } elseif (!file_exists(_PS_ROOT_DIR_ . '/' . self::SETTINGS_FILE) && !is_writable(_PS_ROOT_DIR_ . '/' . dirname(self::SETTINGS_FILE))) {
         $this->setError($this->language->l('%s folder is not writable (check permissions)', dirname(self::SETTINGS_FILE)));
         return false;
     }
     // Generate settings content and write file
     $settings_constants = array('_DB_SERVER_' => $database_server, '_DB_NAME_' => $database_name, '_DB_USER_' => $database_login, '_DB_PASSWD_' => $database_password, '_DB_PREFIX_' => $database_prefix, '_MYSQL_ENGINE_' => $database_engine, '_PS_CACHING_SYSTEM_' => 'CacheMemcache', '_PS_CACHE_ENABLED_' => '0', '_MEDIA_SERVER_1_' => '', '_MEDIA_SERVER_2_' => '', '_MEDIA_SERVER_3_' => '', '_COOKIE_KEY_' => Tools::passwdGen(56), '_COOKIE_IV_' => Tools::passwdGen(8), '_PS_CREATION_DATE_' => date('Y-m-d'), '_PS_VERSION_' => _PS_INSTALL_VERSION_);
     // If mcrypt is activated, add Rijndael 128 configuration
     if (function_exists('mcrypt_encrypt')) {
         $settings_constants['_RIJNDAEL_KEY_'] = Tools::passwdGen(mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB));
         $settings_constants['_RIJNDAEL_IV_'] = base64_encode(mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND));
     }
     $settings_content = "<?php\n";
     foreach ($settings_constants as $constant => $value) {
         $settings_content .= "define('{$constant}', '" . str_replace('\'', '\\\'', $value) . "');\n";
     }
     if (!file_put_contents(_PS_ROOT_DIR_ . '/' . self::SETTINGS_FILE, $settings_content)) {
         $this->setError($this->language->l('Cannot write settings file'));
         return false;
     }
     return true;
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:30,代码来源:install.php


示例5: _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


示例6: __construct

 function __construct($cipher)
 {
     $this->cipher = $cipher;
     $this->key_size = mcrypt_module_get_algo_key_size($cipher);
     $this->block_size = mcrypt_module_get_algo_block_size($cipher);
     $this->iv = str_repeat("", mcrypt_get_iv_size($cipher, 'ncfb'));
 }
开发者ID:CoR--,项目名称:LRphpLib,代码行数:7,代码来源:openpgp_mcrypt_wrapper.php


示例7: decrypted

 public static function decrypted($encrypted, $key)
 {
     $data = base64_decode($encrypted);
     $iv = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
     $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, hash('sha256', $key, true), substr($data, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)), MCRYPT_MODE_CBC, $iv), "");
     return $decrypted;
 }
开发者ID:php-user,项目名称:shop.local,代码行数:7,代码来源:FunctionLibrary.php


示例8: __construct

 /**
  * @param string $cypher
  * @param string $mode
  * @param int    $ivMode
  */
 public function __construct($cypher = MCRYPT_RIJNDAEL_256, $mode = MCRYPT_MODE_ECB, $ivMode = MCRYPT_RAND)
 {
     $this->cypher = $cypher;
     $this->mode = $mode;
     $ivSize = mcrypt_get_iv_size($cypher, $mode);
     $this->iv = mcrypt_create_iv($ivSize, $ivMode);
 }
开发者ID:EdisonValdez,项目名称:IbrowsNewsletterBundle,代码行数:12,代码来源:McryptAdapter.php


示例9: decrypt

 /**
  * 解密函数
  * @param string $decrypt
  * @param string $key
  * @return string
  */
 public function decrypt($decrypt, $key = '')
 {
     $decoded = base64_decode($decrypt);
     $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
     $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), $decoded, MCRYPT_MODE_ECB, $iv);
     return $decrypted;
 }
开发者ID:CCluv,项目名称:php-framework-module,代码行数:13,代码来源:Mcrypt.php


示例10: decrypt

 /**
  * see crypt::decrypt();
  */
 public function decrypt($data)
 {
     if ($this->base64) {
         $decoded = base64_decode($data);
     } else {
         $decoded = $data;
     }
     // extract values out of data
     $iv_size = mcrypt_get_iv_size($this->cipher, $this->mode);
     $iv = mb_substr($decoded, 0, $iv_size, 'latin1');
     $hash_size = mb_strlen($this->hash(1), 'latin1');
     $hash = mb_substr($decoded, $iv_size, $hash_size, 'latin1');
     $cipher = mb_substr($decoded, $iv_size + $hash_size, mb_strlen($decoded, 'latin1'), 'latin1');
     // comparing ciper with hash
     if ($this->hash($cipher) != $hash) {
         return false;
     }
     // decrypting
     $decrypted = mcrypt_decrypt($this->cipher, $this->key, $cipher, $this->mode, $iv);
     if ($decrypted !== false) {
         return rtrim($decrypted, "");
     } else {
         return false;
     }
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:28,代码来源:base.php


示例11: __construct

 public function __construct($key, $mode = MCRYPT_MODE_ECB, $iv = NULL, $bit = AESMcrypt::BIT_128)
 {
     // check mcrypt module
     if (!extension_loaded("mcrypt")) {
         trigger_error('AESMcrypt class need mcrypt module');
         return;
     }
     switch ($bit) {
         case AESMcrypt::BIT_192:
             $this->_cipher = MCRYPT_RIJNDAEL_192;
             break;
         case AESMcrypt::BIT_256:
             $this->_cipher = MCRYPT_RIJNDAEL_256;
             break;
         default:
             $this->_cipher = MCRYPT_RIJNDAEL_128;
             break;
     }
     $modes = array(MCRYPT_MODE_ECB, MCRYPT_MODE_CBC, MCRYPT_MODE_CFB, MCRYPT_MODE_OFB, MCRYPT_MODE_NOFB);
     if (in_array($mode, $modes)) {
         $this->_mode = $mode;
     } else {
         $this->_mode = MCRYPT_MODE_ECB;
     }
     $this->_key = $key;
     $this->_iv = $iv;
     // check iv size, ecb模式不需要iv
     if ($this->_mode != MCRYPT_MODE_ECB) {
         $needIVSize = mcrypt_get_iv_size($this->_cipher, $this->_mode);
         if (strlen($iv) != $needIVSize) {
             trigger_error("IV size wrong, need a string of length {$needIVSize}");
             return;
         }
     }
 }
开发者ID:shushenghong,项目名称:asphp,代码行数:35,代码来源:AESMcrypt.php


示例12: aesdecrypt

function aesdecrypt($s, $key)
{
    $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
    $iv = substr($s, 0, $iv_size);
    $crypto = substr($s, $iv_size);
    return @mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $crypto, MCRYPT_MODE_CBC, $iv);
}
开发者ID:RazorMarx,项目名称:izend,代码行数:7,代码来源:aesencrypt.php


示例13: decrypt

function decrypt($text, $salt)
{
    if (!$text) {
        return false;
    }
    return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}
开发者ID:Carlanga,项目名称:regmyudid.com,代码行数:7,代码来源:ipn.php


示例14: __construct

 public function __construct($encryption_key)
 {
     $this->prefix = version_compare(PHP_VERSION, '5.3.7') < 0 ? '$2a' : '$2y';
     $this->encryptionHash = str_split(hash('sha256', $encryption_key));
     // SHA-256 hash array
     $this->iv_size = mcrypt_get_iv_size($this->cipher, $this->mcryptMode);
 }
开发者ID:johanneskonst,项目名称:hashover-next,代码行数:7,代码来源:encryption.php


示例15: do_encrypt

function do_encrypt($data)
{
    $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
    $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    $encrypt = getEncryptionKey(32);
    return base64_encode($iv . mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $encrypt, $data, MCRYPT_MODE_CBC, $iv));
}
开发者ID:giulianofiorotto,项目名称:IoT-Framework-ESP8266,代码行数:7,代码来源:functions.php


示例16: encryptCookie

function encryptCookie($value)
{
    // serialize array values
    if (!$value) {
        return false;
    }
    if (is_array($value)) {
        $value = serialize($value);
    }
    // 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);
    }
    // generate random value for IV
    $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
    $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    // encrypt the data with the key and IV using AES-256
    $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $value, MCRYPT_MODE_CBC, $iv);
    // generate an SHA-256 HMAC hash where data = encrypted text and key = defined constant
    $signature = hash_hmac('sha256', $crypttext, SIG_HMAC);
    $cookiedough = array();
    $cookiedough['sig'] = $signature;
    $cookiedough['iv'] = $iv;
    $cookiedough['text'] = $crypttext;
    $final = serialize($cookiedough);
    return base64_encode($final);
    //encode for cookie
}
开发者ID:EBSCO-GSS,项目名称:curriculum_builder,代码行数:29,代码来源:app.php


示例17: decrypt

 static function decrypt($string, $date = 0)
 {
     if (empty($string)) {
         return '';
     }
     $key = self::_getKey($date);
     if (!empty($key)) {
         $ciphertext_dec = base64_decode($string);
         if (function_exists('mcrypt_encrypt')) {
             $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
             //vmdebug('decrypt $iv_size', $iv_size ,MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
             // retrieves the IV, iv_size should be created using mcrypt_get_iv_size()
             $iv_dec = substr($ciphertext_dec, 0, $iv_size);
             //retrieves the cipher text (everything except the $iv_size in the front)
             $ciphertext_dec = substr($ciphertext_dec, $iv_size);
             vmdebug('decrypt $iv_dec', $iv_dec, $ciphertext_dec);
             if (empty($iv_dec) and empty($ciphertext_dec)) {
                 vmdebug('Seems something not encrytped should be decrypted, return default ', $string);
                 return $string;
             } else {
                 $mcrypt_decrypt = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec);
                 return rtrim($mcrypt_decrypt, "");
             }
         } else {
             return $ciphertext_dec;
         }
     } else {
         return $string;
     }
 }
开发者ID:juanmcortez,项目名称:Lectorum,代码行数:30,代码来源:vmcrypt.php


示例18: 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


示例19: encrypt

 /**
  * Encrypt a string.
  *
  * @param string $str String to encrypt.
  *
  * @return string
  */
 public function encrypt($str)
 {
     $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
     $str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->key, $str, MCRYPT_MODE_CBC, $iv);
     $str = $iv . $str;
     return base64_encode($str);
 }
开发者ID:JCquence,项目名称:Clockwork,代码行数:14,代码来源:Crypt.php


示例20: hash

 /**
  * [hash description]
  * @param  [type] $_i [description]
  * @return [type]     [description]
  */
 public static function hash($_i)
 {
     $size = mcrypt_get_iv_size(self::MCRYPT_SIZE, self::MCRYPT_MODE);
     $iv = mcrypt_create_iv($size, self::IV_SOURCE);
     $hash = self::pbkdf2(self::HASH_ALGORITHM, $_i, $iv, self::HASH_COUNT, self::OUTPUT_KEY_LEN);
     return $hash . $iv;
 }
开发者ID:karminski,项目名称:salt-fish-raw-php,代码行数:12,代码来源:Encrypt.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP mcrypt_get_key_size函数代码示例发布时间:2022-05-15
下一篇:
PHP mcrypt_get_cipher_name函数代码示例发布时间: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