當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Crypt_Rijndael::setKeyLength方法代碼示例

本文整理匯總了PHP中Crypt_Rijndael::setKeyLength方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crypt_Rijndael::setKeyLength方法的具體用法?PHP Crypt_Rijndael::setKeyLength怎麽用?PHP Crypt_Rijndael::setKeyLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Crypt_Rijndael的用法示例。


在下文中一共展示了Crypt_Rijndael::setKeyLength方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generateKey

 /**
  * @param null|string $input
  * @return string
  */
 public function generateKey($input = NULL)
 {
     $text = $input === NULL ? $this->username . ';' . date('d/m/Y H:i:s') . ';' . $this->ip : $input;
     $cipher = new \Crypt_Rijndael();
     $cipher->setKeyLength(256);
     $cipher->setBlockLength(128);
     $cipher->setKey(base64_decode($this->key));
     $cipher->setIV(base64_decode($this->iv));
     return base64_encode($cipher->encrypt($text));
 }
開發者ID:ondrs,項目名稱:otomoto-api,代碼行數:14,代碼來源:Api.php

示例2: init

 /**
  * Initilizes cryptographic scheme
  */
 private static function init()
 {
     if (is_null(self::$cryptographicScheme)) {
         $key = KeyHandler::readKey();
         $mysqlKey = "";
         for ($a = 0; $a < strlen($key); $a++) {
             $mysqlKey[$a % 16] = chr(ord($mysqlKey[$a % 16]) ^ ord($key[$a]));
         }
         $aes = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_ECB);
         $aes->setKeyLength(128);
         $aes->setBlockLength(128);
         $aes->setKey($mysqlKey);
         self::$cryptographicScheme = $aes;
     }
 }
開發者ID:lahirwisada,項目名稱:orangehrm,代碼行數:18,代碼來源:Cryptographer.php

示例3: setKeyLength

 /**
  * Sets the key length
  *
  * Valid key lengths are 128, 192, and 256.  If the length is less than 128, it will be rounded up to
  * 128.  If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount.
  *
  * @see Crypt_Rijndael:setKeyLength()
  * @access public
  * @param Integer $length
  */
 function setKeyLength($length)
 {
     switch ($length) {
         case 160:
             $length = 192;
             break;
         case 224:
             $length = 256;
     }
     parent::setKeyLength($length);
 }
開發者ID:anthrotech,項目名稱:laravel_sample,代碼行數:21,代碼來源:AES.php

示例4: encrypt

 /**
  *
  * Encrypts given value, with given key, and hex encodes it before
  * returning.
  *
  * Compatible with mysql: "hex(aes_encrypt($val, $key))
  *
  * @param string $val - value to encrypt
  * @param string $ky - key
  * @return string encrypted value
  */
 public function encrypt($val, $key)
 {
     if (empty($val)) {
         return $val;
     }
     $mysqlKey = "";
     for ($a = 0; $a < strlen($key); $a++) {
         $mysqlKey[$a % 16] = chr(ord($mysqlKey[$a % 16]) ^ ord($key[$a]));
     }
     $aes = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_ECB);
     $aes->setKeyLength(128);
     $aes->setBlockLength(128);
     $aes->setKey($mysqlKey);
     $encrypt = $aes->encrypt($val);
     $encrypt = strtoupper(bin2hex($encrypt));
     return $encrypt;
 }
開發者ID:lahirwisada,項目名稱:orangehrm,代碼行數:28,代碼來源:EncryptionListener.php


注:本文中的Crypt_Rijndael::setKeyLength方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。