read() public method

Decrypt a message encrypted with write().
public read ( string $key, $ciphertext ) : string
$key string The key to use for decryption.
return string The plaintext message.
示例#1
0
 /**
  * Returns a value from the internal params array.
  *
  * @param string $key  The param key.
  *
  * @return mixed  The param value, or null if not found.
  */
 public function getParam($key)
 {
     /* Passwords may be stored encrypted. */
     if ($key == 'password' && !empty($this->_params['_passencrypt'])) {
         try {
             $secret = new Horde_Secret();
             return $secret->read($this->_getEncryptKey(), $this->_params['password']);
         } catch (Exception $e) {
             return null;
         }
     }
     return isset($this->_params[$key]) ? $this->_params[$key] : null;
 }
示例#2
0
文件: Smtp.php 项目: jubinpatel/horde
 /**
  * Returns a value from the internal params array.
  *
  * @param string $key  The param key.
  *
  * @return mixed  The param value, or null if not found.
  */
 public function getParam($key)
 {
     /* Passwords may be stored encrypted. */
     switch ($key) {
         case 'password':
         case 'xoauth2_token':
             if (isset($this->_params[$key]) && $this->_params[$key] instanceof Horde_Smtp_Password) {
                 return $this->_params[$key]->getPassword();
             }
             // DEPRECATED
             if ($key == 'password' && !empty($this->_params['_passencrypt'])) {
                 try {
                     $secret = new Horde_Secret();
                     return $secret->read($this->_getEncryptKey(), $this->_params['password']);
                 } catch (Exception $e) {
                     return null;
                 }
             }
             break;
     }
     return isset($this->_params[$key]) ? $this->_params[$key] : null;
 }
示例#3
0
 public function testShortKeyRead()
 {
     $secret = new Horde_Secret();
     $this->assertEquals('', $secret->read('', ""));
 }