Pop\Crypt\Mcrypt::setSource PHP Method

setSource() public method

Method to set the source
public setSource ( integer $source = null ) : self
$source integer
return self
    public function setSource($source = null)
    {
        $this->source = null !== $source ? $source : MCRYPT_RAND;
        return $this;
    }

Usage Example

 /**
  * 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::setSource