/** * Encrypts a message. * * @access public * @see \Topxia\Service\Util\Phpsec\Crypt\Base::decrypt() * @see \Topxia\Service\Util\Phpsec\Crypt\RC4::_crypt() * * @param String $plaintext * @return String $ciphertext */ public function encrypt($plaintext) { if ($this->engine != Base::ENGINE_INTERNAL) { return parent::encrypt($plaintext); } return $this->_crypt($plaintext, self::ENCRYPT); }
/** * Decrypts a message. * * Mostly a wrapper for Crypt_Base::decrypt, with some additional OpenSSL handling code * * @access public * @see encrypt() * * @param String $ciphertext * @return String $plaintext */ public function decrypt($ciphertext) { if ($this->engine == self::ENGINE_OPENSSL) { $temp = $this->key; $this->key = $this->orig_key; $result = parent::decrypt($ciphertext); $this->key = $temp; return $result; } return parent::encrypt($ciphertext); }