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


PHP mcrypt_enc_get_block_size函数代码示例

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


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

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

示例2: encrypt

 public function encrypt($origData)
 {
     $origData = pkcs5padding($origData, mcrypt_enc_get_block_size($this->encrypter));
     mcrypt_generic_init($this->encrypter, $this->key, substr($this->key, 0, 16));
     $ciphertext = mcrypt_generic($this->encrypter, $origData);
     mcrypt_generic_deinit($this->encrypter);
     return $ciphertext;
 }
开发者ID:victor-u,项目名称:encryption-aes,代码行数:8,代码来源:aescrypter.php

示例3: getAuthCode

 public static function getAuthCode($uid)
 {
     $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
     mcrypt_generic_init($td, self::$authKey, self::$authIv);
     $lose_time = time() + self::$timeLimit;
     $_authstr = $uid . '_' . $lose_time;
     $blockSize = mcrypt_enc_get_block_size($td);
     $_authstr = self::pkcs5_pad($_authstr, $blockSize);
     $encrypted = mcrypt_generic($td, $_authstr);
     $mdata = base64_encode($encrypted);
     return $mdata;
 }
开发者ID:phpxin,项目名称:chatserver,代码行数:12,代码来源:ApiLoginLogic.class.php

示例4: __construct

 /**
  * @param string $key encryption key should be 16, 24 or 32 characters long form 128, 192, 256 bit encryption
  */
 public function __construct($key)
 {
     $this->mcryptModule = mcrypt_module_open('rijndael-256', '', 'cbc', '');
     if ($this->mcryptModule === false) {
         throw new \InvalidArgumentException("Unknown algorithm/mode.");
     }
     $keyLength = strlen($key);
     if ($keyLength > ($keyMaxLength = mcrypt_enc_get_key_size($this->mcryptModule))) {
         throw new \InvalidArgumentException("The key length must be less or equal than {$keyMaxLength}.");
     }
     if (!in_array($keyLength, array(16, 24, 32))) {
         throw new \InvalidArgumentException("Key length must be 16, 24 or 32 bytes for 128, 192, 256 bit encryption.");
     }
     $this->key = $key;
     $this->initializationVectorSize = mcrypt_enc_get_iv_size($this->mcryptModule);
     $this->blockSize = mcrypt_enc_get_block_size($this->mcryptModule);
 }
开发者ID:stikmanw,项目名称:rest-event-framework,代码行数:20,代码来源:AesEncryptor.php

示例5: encrypt

 public function encrypt(string $data, string $key, bool $encode = true) : string
 {
     if (strlen($key) == 0) {
         throw new CryptException("You need to supply a password for the encryption");
     }
     $fd = mcrypt_module_open($this->mCipher, "", $this->mMode, "");
     if (is_resource($fd)) {
         $ivSize = mcrypt_enc_get_iv_size($fd);
         $keySize = mcrypt_enc_get_key_size($fd);
         $blocksize = mcrypt_enc_get_block_size($fd);
         /*
          * The chosen algorithm might not always want the IV, but we still need one for our own checks and key generation
          */
         if ($keySize <= 0) {
             throw new CryptException("Key Size is to small");
         } elseif ($ivSize <= 0) {
             $ivSize = $keySize;
         }
         if ($blocksize <= 0) {
             throw new CryptException("Invalid block size");
         }
         $iv = random_bytes($ivSize);
         $kdf = $this->kdf($key, $keySize, $iv, true);
         if ($this->mTwoStep) {
             $data = $this->sign($data, $key);
         } else {
             $data = "raw:{$data}";
         }
         $result = mcrypt_generic_init($fd, $kdf, $iv);
         if ($result !== 0) {
             throw new CryptException("Initiation error ({$result})");
         }
         $data = mcrypt_generic($fd, $this->pad($data, $blocksize));
         $data = $this->sign($data, $kdf, $iv);
         mcrypt_generic_deinit($fd);
         mcrypt_module_close($fd);
         return $this->mask($data, $key, $encode);
     } else {
         throw new Exception("Could not open the MCrypt module");
     }
     return null;
 }
开发者ID:IMPHP,项目名称:libimphp,代码行数:42,代码来源:Encrypter.php

示例6: __construct

 /**
  * @param string    $key      base64-encoded encryption key
  * @param integer   $key_len  length of raw key in bits
  */
 public function __construct($key, $key_len = 192)
 {
     $this->_td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
     $key = self::urlsafe_b64decode($key);
     if (strlen($key) != $key_len / 8) {
         $len = strlen($key);
         $expected = $key_len / 8;
         throw new Fuze_Crypt_Exception("Incorrect key length: got {$len} bytes, expected {$expected}");
     }
     if (strlen($key) > mcrypt_enc_get_key_size($this->_td)) {
         $max = mcrypt_enc_get_key_size($this->_td);
         throw new Fuze_Crypt_Exception("Given key is longer than {$max} bytes");
     }
     $iv_size = mcrypt_enc_get_iv_size($this->_td);
     $block_size = mcrypt_enc_get_block_size($this->_td);
     if ($iv_size != self::AES_BLOCK_SIZE || $block_size != self::AES_BLOCK_SIZE) {
         throw new Fuze_Crypt_Exception('Incorrect IV or block size!');
     }
     $this->_key = $key;
 }
开发者ID:nsegreto,项目名称:fuze,代码行数:24,代码来源:Crypt.php

示例7: openSRS_crypt

 function openSRS_crypt($key, $cipher = 'DES')
 {
     if (!extension_loaded('mcrypt')) {
         throw new Exception("oSRS Error - mcrypt module is not compiled into PHP");
     }
     if (!function_exists('mcrypt_module_open')) {
         throw new Exception("oSRS Error - libmcrypt version insufficient");
     }
     if (function_exists('mcrypt_generic_deinit')) {
         $this->deinit_function = 'mcrypt_generic_deinit';
     } else {
         if (function_exists('mcrypt_generic_end')) {
             $this->deinit_function = 'mcrypt_generic_end';
         } else {
             throw new Exception("oSRS Error - PHP version insufficient");
         }
     }
     srand((double) microtime() * 1000000);
     $this->header_spec = 'RandomIV';
     if (!$key) {
         throw new Exception("oSRS Error - no key specified");
     }
     $cipher = strtoupper($cipher);
     // check for cipher
     if (!isset($this->known_ciphers[$cipher])) {
         throw new Exception("oSRS Error - unknown cipher - " . $cipher);
     }
     $this->cipher = $this->known_ciphers[$cipher];
     // initialize cipher
     $this->TD = mcrypt_module_open($this->cipher, '', 'ecb', '');
     $this->blocksize = mcrypt_enc_get_block_size($this->TD);
     $this->keysize = mcrypt_enc_get_key_size($this->TD);
     // mangle key with MD5
     $this->keyhash = $this->_md5perl($key);
     while (strlen($this->keyhash) < $this->keysize) {
         $this->keyhash .= $this->_md5perl($this->keyhash);
     }
     $this->key = substr($this->keyhash, 0, $this->keysize);
     return true;
 }
开发者ID:OpenSRS,项目名称:openSRS-SiteLock,代码行数:40,代码来源:openSRS_crypt.php

示例8: decryptString

 function decryptString($ciphertext)
 {
     $bs = mcrypt_enc_get_block_size($this->cipher);
     // get block size
     $iv_size = mcrypt_enc_get_iv_size($this->cipher);
     if (strlen($ciphertext) % $bs != 0) {
         // check string is proper size
         exit(1);
     }
     $iv = substr($ciphertext, 0, $iv_size);
     // retrieve IV
     $ciphertext = substr($ciphertext, $iv_size);
     mcrypt_generic_init($this->cipher, $this->key, $iv);
     $result = mdecrypt_generic($this->cipher, $ciphertext);
     // decrypt
     //echo var_dump(unpack('c*',$iv))."\n";
     $padding = ord(substr($result, -1));
     // retrieve padding
     $result = substr($result, 0, $padding * -1);
     // and remove it
     mcrypt_generic_deinit($this->cipher);
     return $result;
 }
开发者ID:ccovey,项目名称:openfire-blowfish,代码行数:23,代码来源:OpenFireBlowFish.php

示例9: decrypt

 /**
  * Decrypts an encrypted text
  *
  *<code>
  *    echo $crypt->decrypt($encrypted, "decrypt password");
  *</code>
  *
  * @param string $text
  * @param string $key
  *
  * @return string
  * @throws \ManaPHP\Security\Crypt\Exception
  */
 public function decrypt($text, $key = null)
 {
     if ($key === null) {
         $key = $this->_key;
     }
     $ivSize = mcrypt_enc_get_block_size($this->_mcrypt);
     if (strlen($text) < $ivSize * 3) {
         throw new CryptException('encrypted data is too short.');
     }
     $encryptKey = md5($key, true);
     mcrypt_generic_init($this->_mcrypt, $encryptKey, substr($text, 0, $ivSize));
     $decrypted = mdecrypt_generic($this->_mcrypt, substr($text, $ivSize));
     $length = unpack('N', $decrypted)[1];
     if ($length < 16 || 4 + $length > strlen($decrypted)) {
         throw new CryptException('decrypted data length is too short.');
     }
     $decrypted = substr($decrypted, 4, $length);
     $plainText = substr($decrypted, 0, -16);
     if (md5($plainText, true) !== substr($decrypted, -16)) {
         throw new CryptException('decrypted md5 is not valid.');
     }
     return $plainText;
 }
开发者ID:manaphp,项目名称:manaphp,代码行数:36,代码来源:Crypt.php

示例10: Decrypt

 public function Decrypt($strEncryptedData)
 {
     // Initialize Encryption
     $intReturnValue = mcrypt_generic_init($this->objMcryptModule, $this->strKey, $this->strIv);
     if ($intReturnValue === false || $intReturnValue < 0) {
         throw new QCryptographyException('Incorrect Parameters used in LibMcrypt Initialization');
     }
     if ($this->blnBase64) {
         $strEncryptedData = str_replace('_', '/', $strEncryptedData);
         $strEncryptedData = str_replace('-', '+', $strEncryptedData);
         $strEncryptedData = base64_decode($strEncryptedData);
     }
     $intBlockSize = mcrypt_enc_get_block_size($this->objMcryptModule);
     $strDecryptedData = mdecrypt_generic($this->objMcryptModule, $strEncryptedData);
     // Figure Out Length and Truncate
     $intPosition = strpos($strDecryptedData, '/');
     if (!$intPosition) {
         throw new QCryptographyException('Invalid Length Header in Decrypted Data');
     }
     $intLength = substr($strDecryptedData, 0, $intPosition);
     $strDecryptedData = substr($strDecryptedData, $intPosition + 1);
     $strDecryptedData = substr($strDecryptedData, 0, $intLength);
     // Deinitialize Encryption
     if (!mcrypt_generic_deinit($this->objMcryptModule)) {
         throw new QCryptographyException('Unable to deinitialize encryption buffer');
     }
     return $strDecryptedData;
 }
开发者ID:eliud254,项目名称:q-auction,代码行数:28,代码来源:QCryptography.class.php

示例11: Crypt_CBC

 /**
  * Constructor
  * $key is the key to use for encryption. $cipher can be DES, BLOWFISH or
  * BLOWFISH-COMPAT
  *
  * @param    $key        encryption key
  * @param    $cipher     which algorithm to use, defaults to DES
  *
  * @return   $return     either a PEAR error or true
  *
  * @access   public
  *
  */
 function Crypt_CBC($key, $cipher = 'DES')
 {
     if (!extension_loaded('mcrypt')) {
         return $this->raiseError('mcrypt module is not compiled into PHP', null, PEAR_ERROR_DIE, null, 'compile PHP using "--with-mcrypt"');
     }
     if (!function_exists('mcrypt_module_open')) {
         return $this->raiseError('libmcrypt version insufficient', null, PEAR_ERROR_DIE, null, 'this class requires libmcrypt >= 2.4.x, preferably >= 2.5.5');
     }
     if (function_exists('mcrypt_generic_deinit')) {
         $this->deinit_function = 'mcrypt_generic_deinit';
     } else {
         if (function_exists('mcrypt_generic_end')) {
             $this->deinit_function = 'mcrypt_generic_end';
         } else {
             return $this->raiseError('PHP version insufficient', null, PEAR_ERROR_DIE, null, 'this class requires PHP >= 4.0.2, preferably >= 4.1.1');
         }
     }
     /* seed randomizer */
     srand((double) microtime() * 1000000);
     /* initialize */
     $this->header_spec = 'RandomIV';
     /* check for key */
     if (!$key) {
         return $this->raiseError('no key specified');
     }
     /* check for cipher */
     $cipher = strtoupper($cipher);
     if (!isset($this->known_ciphers[$cipher])) {
         return $this->raiseError('unknown cipher "' . $cipher . '"');
     }
     $this->cipher = $this->known_ciphers[$cipher];
     /* initialize cipher */
     $this->TD = mcrypt_module_open($this->cipher, '', 'ecb', '');
     $this->blocksize = mcrypt_enc_get_block_size($this->TD);
     $this->keysize = mcrypt_enc_get_key_size($this->TD);
     /* mangle key with MD5 */
     $this->keyhash = $this->_md5perl($key);
     while (strlen($this->keyhash) < $this->keysize) {
         $this->keyhash .= $this->_md5perl($this->keyhash);
     }
     $this->key = substr($this->keyhash, 0, $this->keysize);
     return true;
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:56,代码来源:CBC.php

示例12: _Decryption_Loop

 function _Decryption_Loop()
 {
     // If legacy drop to legacy function
     if ($this->job['legacy']) {
         return $this->_Legacy_Decryption_Loop();
     }
     // Grab the real block size and adjust the configured block size to ensure it is an exact divisor
     $real_blocksize = mcrypt_enc_get_block_size($this->cipher);
     $blocksize = $this->WPOnlineBackup->Get_Setting('max_block_size');
     if (($rem = $blocksize % $real_blocksize) != 0) {
         $blocksize += $real_blocksize - $rem;
     }
     // Grab total length of data - increase it to block size and calculate the amount we'll need to trim after decryption
     $len = $this->job['header']['len'];
     if (($rem = $len % $real_blocksize) != 0) {
         $len += $trim = $real_blocksize - $rem;
     } else {
         $trim = 0;
     }
     // Take off what we've already done
     $len -= $this->job['done_bytes'];
     // Decrypt loop - if we've already done the last block break out
     while ($len - $trim > 0) {
         $block = min($blocksize, $len);
         if (($data = @fread($this->file, $block)) === false) {
             return OBFW_Exception();
         }
         if (strlen($data) != $block) {
             return 'Partially read ' . strlen($data) . ' of ' . $block . ' bytes from encrypted data file for decryption.';
         }
         // Change the IV for the next block to the encrypted data of the last block we're about to decrypt
         $this->job['current_iv'] = substr($data, $block - $real_blocksize, $real_blocksize);
         $data = mdecrypt_generic($this->cipher, $data);
         if (($len -= $block) <= 0) {
             if ($trim != 0) {
                 $data = substr($data, 0, $trim * -1);
             }
         }
         $block = strlen($data);
         if (true !== ($ret = $this->stream->Write($data))) {
             return 'Write to stream failed. ' . $ret;
         }
         if ($this->hash_ctx !== false) {
             hash_update($this->hash_ctx, $data);
             $this->job['hash_len'] += $block;
         } else {
             if ($this->job['crc'] !== false) {
                 $this->job['crc'] = WPOnlineBackup_Functions::Combine_CRC32($this->job['crc'], crc32($data), $block);
             } else {
                 $this->job['crc'] = crc32($data);
             }
         }
         $this->job['done_bytes'] += $block;
         // Update the progress
         if ($this->job['done_bytes'] >= $this->job['header']['len']) {
             $this->job['progress'] = 99;
         } else {
             $this->job['progress'] = 10 + floor($this->job['done_bytes'] * 89 / $this->job['header']['len']);
             if ($this->job['progress'] > 99) {
                 $this->job['progress'] = 99;
             }
         }
         $this->bootstrap->Tick();
     }
     if ($this->hash_ctx !== false && $this->job['hash_len'] > 0) {
         list($crc) = array_values(unpack('N', hash_final($this->hash_ctx, true)));
         if ($this->job['crc'] !== false) {
             $this->job['crc'] = WPOnlineBackup_Functions::Combine_CRC32($this->job['crc'], $crc, $this->job['hash_len']);
         } else {
             $this->job['crc'] = $crc;
         }
         $this->hash_ctx = false;
     }
     if ($this->job['crc'] != $this->job['header']['crc']) {
         return false;
     }
     $this->bootstrap->Log_Event(WPONLINEBACKUP_EVENT_INFORMATION, 'File integrity check was successful.');
     // Prevent duplicated messages
     $this->bootstrap->Tick(false, true);
     return true;
 }
开发者ID:panser,项目名称:wandromaha,代码行数:81,代码来源:decrypt.php

示例13: mcrypt_ofb

$key = "123456789012345678901234567890123456789012345678901234567890";
$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", "");
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ext_mcrypt.php

示例14: logfrm_proc

 /**
 	| @name
 	|      - logfrm_proc
 	|
 	| @params
 	|      - 
 	|
 	| @return
 	|      - 
 	|
 	| @description
 	|      - process new user profile
 	|
 	**/
 function logfrm_proc()
 {
     global $g_SYSTEM_DATA;
     $this->etc->sec_logout();
     //params
     log_message("INFO", "logfrm_proc() : start here");
     $chiphername = mcrypt_enc_get_algorithms_name($cipher);
     $blocksize = mcrypt_enc_get_block_size($cipher);
     $mykeysize = mcrypt_enc_get_supported_key_sizes($cipher);
     log_message("INFO", "logfrm_proc() : {$chiphername}/{$blocksize} bytes ");
     foreach ($mykeysize as $value) {
         log_message("INFO", "logfrm_proc() : {$value} bytes ");
     }
     unset($value);
     //sess
     $dmp = @var_export($g_SYSTEM_DATA['_SESSION'], true);
     //get chk post
     $email = trim($this->input->post('email'));
     $pass = trim($this->input->post('pass'));
     $me = @intval(trim($this->input->post('me')));
     //params
     log_message("INFO", "logfrm_proc() : info-params [ {$email} : {$pass} : {$me} ] {$dmp};");
     //cancel?
     if (!$this->input->get_post('Login')) {
         //set status
         log_message("INFO", "logfrm_proc() : info [ NOT CLICKED ]");
         //fwd
         redirect(site_url(DEFAULT_LOGGED_IN_PAGE));
         return;
     }
     //exec
     $pdata = $this->etc->sec_login($email, $pass, $me);
     $dmp = @var_export($pdata, true);
     $by = $this->etc->get_name();
     log_message("INFO", "logfrm_proc() : INFO-LOGIN [ {$dmp}  ]");
     if (!$pdata['status']) {
         //set status
         $smsg = intval($pdata['pdata']['data']->fieldtrial) >= intval($pdata['pdata']['data']->trial) ? $this->config->item('USER_LOGIN_ERROR_MAX') : $this->config->item('USER_LOGIN_ERROR');
         $this->etc->set_error_message($smsg);
         log_message("INFO", "logfrm_proc() : INFO-LOGIN-ERR [ {$smsg} ]");
         //fwd
         redirect(site_url(DEFAULT_LOGGED_IN_PAGE));
         return;
     }
     //chk if its locked ???
     if (intval($pdata['pdata']['data']->fieldtrial) >= intval($pdata['pdata']['data']->trial)) {
         //max reached
         $this->etc->set_error_message($this->config->item('USER_LOGIN_ERROR_MAX'));
         log_message("INFO", "logfrm_proc() : INFO-LOGIN-ERR [ LOCKED ]");
         //fwd
         redirect(site_url(DEFAULT_LOGGED_IN_PAGE));
         return;
     }
     //pass expired
     if (intval($pdata['pdata']['data']->expired) > 0) {
         //max reached
         $this->etc->set_error_message($this->config->item('USER_LOGIN_PASS_EXPIRED'));
         log_message("INFO", "logfrm_proc() : INFO-LOGIN-ERR [ PWD-EXPIRED ]");
         //fwd
         redirect(site_url(DEFAULT_LOGGED_IN_PAGE));
         return;
     }
     //in-active
     if (intval($pdata['pdata']['data']->flag_id) != 1) {
         //max reached
         $this->etc->set_error_message($this->config->item('USER_LOGIN_IN_ACTIVE'));
         log_message("INFO", "logfrm_proc() : INFO-LOGIN-ERR [ IN-ACTIVE ]");
         //fwd
         redirect(site_url(DEFAULT_LOGGED_IN_PAGE));
         return;
     }
     //flag_first=1, then fwd to change pass	and NOT SUPER ROOT + can_change
     if (intval($pdata['pdata']['data']->flagfirst) == 1 && intval($pdata['pdata']['data']->can_change) == 1 && intval($pdata['pdata']['data']->usertype) != DEFAULT_USERTYPE_ROOT_ID) {
         /**
         			//FLAGFIRST++ ( HOW MANY TIMES LOGGED IN)
         			$this->secuser_model->set_column_ctr(array(
         					'id'  => $pdata['pdata']['data']->user_id,
         					'by'  => $by,
         					'col' => 'FLAGFIRST',
         					'val' => sprintf("%d",1+$pdata['pdata']['data']->flagfirst)));
         			**/
         log_message("INFO", "afrm_proc() : INFO-LOGIN [ FLAGFIRST=1 ]");
         redirect(site_url('secuser/chpass'));
         return;
     }
     log_message("INFO", "afrm_proc() : login is GOOD [ goto admin ]");
//.........这里部分代码省略.........
开发者ID:bayugyug,项目名称:unov2,代码行数:101,代码来源:secuser.php

示例15: _genEncryption

 /**
  * Generates Encryption Header message part.
  *
  * @param string $key       Key generated from the password and salt
  * @param string $plainText Request message type data
  *
  * @return array
  * @throws Net_Growl_Exception on wrong hash/crypt algorithms usage
  */
 private function _genEncryption($key, $plainText)
 {
     static $ivVal;
     $hash_algorithm = strtolower($this->options['passwordHashAlgorithm']);
     $crypt_algorithm = strtolower($this->options['encryptionAlgorithm']);
     $crypt_mode = MCRYPT_MODE_CBC;
     $k = array_search($hash_algorithm, $this->_passwordHashAlgorithm);
     switch ($crypt_algorithm) {
         case 'aes':
             if ($k < 2) {
                 $message = "Password hash ({$hash_algorithm})" . " and encryption ({$crypt_algorithm}) algorithms" . " are not compatible." . " Please uses SHA256 or SHA512 instead.";
                 throw new Net_Growl_Exception($message);
             }
             $cipher = MCRYPT_RIJNDAEL_128;
             // Be compatible with Gfw 2, PHP Mcrypt ext. returns 32 in this case
             $key_size = 24;
             break;
         case 'des':
             $cipher = MCRYPT_DES;
             break;
         case '3des':
             if ($k < 2) {
                 $message = "Password hash ({$hash_algorithm})" . " and encryption ({$crypt_algorithm}) algorithms" . " are not compatible." . " Please uses SHA256 or SHA512 instead.";
                 throw new Net_Growl_Exception($message);
             }
             $cipher = MCRYPT_3DES;
             break;
         case 'none':
             // No encryption required
             return array('NONE', $plainText);
         default:
             // Encryption algorithm unknown
             $message = "Invalid encryption algorithm ({$crypt_algorithm})";
             throw new Net_Growl_Exception($message);
     }
     // All encryption algorithms should use
     // a block mode of CBC (Cipher Block Chaining)
     $td = mcrypt_module_open($cipher, '', $crypt_mode, '');
     $iv_size = mcrypt_enc_get_iv_size($td);
     $block_size = mcrypt_enc_get_block_size($td);
     if (!isset($key_size)) {
         $key_size = mcrypt_enc_get_key_size($td);
     }
     // Here's our 128-bit IV which is used for both 256-bit and 128-bit keys.
     if (!isset($ivVal)) {
         $ivVal = mcrypt_create_iv($iv_size, MCRYPT_RAND);
     }
     $ivHex = bin2hex($ivVal);
     // Different encryption algorithms require different key lengths
     // and IV sizes, so use the first X bytes of the key as required.
     $key = substr($key, 0, $key_size);
     $init = mcrypt_generic_init($td, $key, $ivVal);
     if ($init != -1) {
         if ($crypt_mode == MCRYPT_MODE_CBC) {
             /**
              * Pads a string using the RSA PKCS7 padding standards
              * so that its length is a multiple of the blocksize.
              * $block_size - (strlen($text) % $block_size) bytes are added,
              * each of which is equal to
              * chr($block_size - (strlen($text) % $block_size)
              */
             $length = $this->strByteLen($plainText);
             $pad = $block_size - $length % $block_size;
             $plainText = str_pad($plainText, $length + $pad, chr($pad));
         }
         $cipherText = mcrypt_generic($td, $plainText);
         mcrypt_generic_deinit($td);
         mcrypt_module_close($td);
     } else {
         $cipherText = $plainText;
     }
     return array(strtoupper("{$crypt_algorithm}:{$ivHex}"), $cipherText);
 }
开发者ID:klagler,项目名称:Caller-ID-Superfecta,代码行数:82,代码来源:Gntp.php


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