Pop\Crypt\Mcrypt::setMode PHP Method

setMode() public method

Method to set the mode
public setMode ( integer $mode = null ) : self
$mode integer
return self
    public function setMode($mode = null)
    {
        $this->mode = null !== $mode ? $mode : MCRYPT_MODE_CBC;
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Static method decrypt a field value
  *
  * @param  string $value
  * @param  int    $encryption
  * @param  array  $options
  * @return string
  */
 public static function decrypt($value, $encryption, $options = array())
 {
     $decValue = $value;
     $salt = !empty($options['salt']) ? $options['salt'] : null;
     // Decrypt the value
     switch ($encryption) {
         case Auth::ENCRYPT_NONE:
             $decValue = $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']);
             }
             $decValue = $crypt->decrypt($value);
             break;
         default:
             $decValue = '[Encrypted]';
     }
     return $decValue;
 }
All Usage Examples Of Pop\Crypt\Mcrypt::setMode