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


PHP Base::setKeyLength方法代码示例

本文整理汇总了PHP中Base::setKeyLength方法的典型用法代码示例。如果您正苦于以下问题:PHP Base::setKeyLength方法的具体用法?PHP Base::setKeyLength怎么用?PHP Base::setKeyLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Base的用法示例。


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

示例1: setKeyLength

    /**
     * Sets the key length.
     *
     * Valid key lengths are 8 to 1024.
     * Calling this function after setting the key has no effect until the next
     *  \phpseclib\Crypt\RC2::setKey() call.
     *
     * @access public
     * @param int $length in bits
     */
    function setKeyLength($length)
    {
        if ($length < 8) {
            $this->default_key_length = 8;
        } elseif ($length > 1024) {
            $this->default_key_length = 128;
        } else {
            $this->default_key_length = $length;
        }
        $this->current_key_length = $this->default_key_length;

        parent::setKeyLength($length);
    }
开发者ID:juggernautsei,项目名称:openemr,代码行数:23,代码来源:RC2.php

示例2: setKeyLength

 /**
  * Sets the key length.
  *
  * Valid key lengths are 128, 192 or 256 bits
  *
  * @access public
  * @param int $length
  */
 function setKeyLength($length)
 {
     switch ($length) {
         case 128:
         case 192:
         case 256:
             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::setKeyLength($length);
 }
开发者ID:paragonie-scott,项目名称:phpseclib,代码行数:20,代码来源:Twofish.php

示例3: setKeyLength

 /**
  * Sets the key length
  *
  * Keys can be between 1 and 256 bytes long.
  *
  * @access public
  * @param int $length
  * @throws \LengthException if the key length is invalid
  */
 function setKeyLength($length)
 {
     if ($length < 8 || $length > 2048) {
         throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys between 1 and 256 bytes are supported');
     }
     $this->key_length = $length >> 3;
     parent::setKeyLength($length);
 }
开发者ID:paragonie-scott,项目名称:phpseclib,代码行数:17,代码来源:RC4.php

示例4: setKeyLength

 /**
  * Sets the key length.
  *
  * Key lengths can be between 32 and 448 bits.
  *
  * @access public
  * @param int $length
  */
 function setKeyLength($length)
 {
     if ($length < 32 || $length > 448) {
         throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys of sizes between 32 and 448 bits are supported');
     }
     $this->key_length = $length >> 3;
     parent::setKeyLength($length);
 }
开发者ID:paragonie-scott,项目名称:phpseclib,代码行数:16,代码来源:Blowfish.php

示例5: setKeyLength

 /**
  * Sets the key length.
  *
  * Valid key lengths are 128, 192 or 256 bits
  *
  * @access public
  * @param int $length
  */
 function setKeyLength($length)
 {
     switch (true) {
         case $length <= 128:
             $this->key_length = 16;
             break;
         case $length <= 192:
             $this->key_length = 24;
             break;
         default:
             $this->key_length = 32;
     }
     parent::setKeyLength($length);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:22,代码来源:Twofish.php

示例6: setKeyLength

 /**
  * Sets the key length.
  *
  * Valid key lengths are 128, 160, 192, 224, and 256.
  *
  * Note: phpseclib extends Rijndael (and AES) for using 160- and 224-bit keys but they are officially not defined
  *       and the most (if not all) implementations are not able using 160/224-bit keys but round/pad them up to
  *       192/256 bits as, for example, mcrypt will do.
  *
  *       That said, if you want be compatible with other Rijndael and AES implementations,
  *       you should not setKeyLength(160) or setKeyLength(224).
  *
  * Additional: In case of 160- and 224-bit keys, phpseclib will/can, for that reason, not use
  *             the mcrypt php extension, even if available.
  *             This results then in slower encryption.
  *
  * @access public
  * @throws \LengthException if the key length is invalid
  * @param int $length
  */
 function setKeyLength($length)
 {
     switch ($length) {
         case 128:
         case 160:
         case 192:
         case 224:
         case 256:
             $this->key_length = $length >> 3;
             break;
         default:
             throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys of sizes 128, 160, 192, 224 or 256 bits are supported');
     }
     parent::setKeyLength($length);
 }
开发者ID:paragonie-scott,项目名称:phpseclib,代码行数:35,代码来源:Rijndael.php

示例7: setKeyLength

 /**
  * Sets the key length.
  *
  * Key lengths can be between 32 and 448 bits.
  *
  * @access public
  * @param int $length
  */
 function setKeyLength($length)
 {
     if ($length < 32) {
         $this->key_length = 7;
     } elseif ($length > 448) {
         $this->key_length = 56;
     } else {
         $this->key_length = $length >> 3;
     }
     parent::setKeyLength($length);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:Blowfish.php

示例8: setKeyLength

 /**
  * Sets the key length
  *
  * Keys can be between 1 and 256 bytes long.
  *
  * @access public
  * @param int $length
  */
 function setKeyLength($length)
 {
     if ($length < 8) {
         $this->key_length = 1;
     } elseif ($length > 2048) {
         $this->key_length = 256;
     } else {
         $this->key_length = $length >> 3;
     }
     parent::setKeyLength($length);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:RC4.php


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