/** * Encrypt value according to the field crypt property * * @param string $value * @return string */ public function cryptValue($value) { load_class('Q\\Crypt'); return empty($this['crypt']) || !isset($value) ? $value : Crypt::with($this['crypt'])->encrypt($value); }
/** * Return a checksum hash to identify the user and session. * * @param string $salt * @return string */ public function checksum($salt = null) { if (!isset($this->info) && !$this->getInfo()) { return null; } if (is_string($this->store)) { $this->store = extract_dsn($this->store); } if (!$this->checksumCrypt instanceof Crypt) { $this->checksumCrypt = Crypt::with($this->checksumCrypt); } if (empty($this->checksumCrypt->secret) && !$this->checksumPassword) { throw new Exception("To create a checksum, either the password needs to be included or a secret key needs to be used."); } return $this->checksumCrypt->encrypt((isset($this->info['uid']) ? $this->info['uid'] : $this->info['username']) . ($this->checksumPassword ? $this->getUser()->getPassword() : null) . ($this->checksumClientIp ? HTTP::getClientRoute() : null) . ($this->store['driver'] == 'session' ? session_id() : null), $salt); }