Pop\Crypt\Sha::setRounds PHP Method

setRounds() public method

Method to set the rounds
public setRounds ( integer $rounds = 5000 ) : self
$rounds integer
return self
    public function setRounds($rounds = 5000)
    {
        $rounds = (int) $rounds;
        if ($rounds < 1000) {
            $rounds = 1000;
        } else {
            if ($rounds > 999999999) {
                $rounds = 999999999;
            }
        }
        $this->rounds = $rounds;
        return $this;
    }

Usage Example

 /**
  * Static method encrypt a field value
  *
  * @param  string $value
  * @param  int    $encryption
  * @param  array  $options
  * @return string
  */
 public static function encrypt($value, $encryption, $options = array())
 {
     $encValue = $value;
     $salt = !empty($options['salt']) ? $options['salt'] : null;
     // Encrypt the value
     switch ($encryption) {
         case Auth::ENCRYPT_CRYPT_SHA_512:
             $crypt = new Crypt\Sha(512);
             $crypt->setSalt($salt);
             // Set rounds, if applicable
             if (!empty($options['rounds'])) {
                 $crypt->setRounds($options['rounds']);
             }
             $encValue = $crypt->create($value);
             break;
         case Auth::ENCRYPT_CRYPT_SHA_256:
             $crypt = new Crypt\Sha(256);
             $crypt->setSalt($salt);
             // Set rounds, if applicable
             if (!empty($options['rounds'])) {
                 $crypt->setRounds($options['rounds']);
             }
             $encValue = $crypt->create($value);
             break;
         case Auth::ENCRYPT_CRYPT_MD5:
             $crypt = new Crypt\Md5();
             $crypt->setSalt($salt);
             $encValue = $crypt->create($value);
             break;
         case Auth::ENCRYPT_MCRYPT:
             $crypt = new Crypt\Mcrypt();
             $crypt->setSalt($salt);
             // Set cipher, mode and source, if applicable
             if (!empty($options['cipher'])) {
                 $crypt->setCipher($options['cipher']);
             }
             if (!empty($options['mode'])) {
                 $crypt->setMode($options['mode']);
             }
             if (!empty($options['source'])) {
                 $crypt->setSource($options['source']);
             }
             $encValue = $crypt->create($value);
             break;
         case Auth::ENCRYPT_BCRYPT:
             $crypt = new Crypt\Bcrypt();
             $crypt->setSalt($salt);
             // Set cost and prefix, if applicable
             if (!empty($options['cost'])) {
                 $crypt->setCost($options['cost']);
             }
             if (!empty($options['prefix'])) {
                 $crypt->setPrefix($options['prefix']);
             }
             $encValue = $crypt->create($value);
             break;
         case Auth::ENCRYPT_CRYPT:
             $crypt = new Crypt\Crypt();
             $crypt->setSalt($salt);
             $encValue = $crypt->create($value);
             break;
         case Auth::ENCRYPT_SHA1:
             $encValue = sha1($value);
             break;
         case Auth::ENCRYPT_MD5:
             $encValue = md5($value);
             break;
         case Auth::ENCRYPT_NONE:
             $encValue = $value;
             break;
     }
     return $encValue;
 }
All Usage Examples Of Pop\Crypt\Sha::setRounds