コード例 #1
0
ファイル: AES.php プロジェクト: bitking/sysPass
 /**
  * Sets the key.
  *
  * Rijndael supports five different key lengths, AES only supports three.
  *
  * @see \phpseclib\Crypt\Rijndael:setKey()
  * @see setKeyLength()
  * @access public
  * @param string $key
  */
 function setKey($key)
 {
     parent::setKey($key);
     if (!$this->explicit_key_length) {
         $length = strlen($key);
         switch (true) {
             case $length <= 16:
                 $this->key_size = 16;
                 break;
             case $length <= 24:
                 $this->key_size = 24;
                 break;
             default:
                 $this->key_size = 32;
         }
         $this->_setEngine();
     }
 }
コード例 #2
0
ファイル: AES.php プロジェクト: phpseclib/phpseclib
 /**
  * Sets the key.
  *
  * Rijndael supports five different key lengths, AES only supports three.
  *
  * @see \phpseclib\Crypt\Rijndael:setKey()
  * @see setKeyLength()
  * @access public
  * @param string $key
  * @throws \LengthException if the key length isn't supported
  */
 function setKey($key)
 {
     switch (strlen($key)) {
         case 16:
         case 24:
         case 32:
             break;
         default:
             throw new \LengthException('Key of size ' . strlen($key) . ' not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported');
     }
     parent::setKey($key);
 }