*/
public function write($key, $message)
{
- if (!is_string($message)) {
- throw new Horde_Secret_Exception('Plain text must be a string', 0);
- }
-
+ $message = (string) $message;
if (strlen($key) && strlen($message)) {
return $this->_getCipherOb($key)->encrypt($message);
} else {
*/
public function read($key, $ciphertext)
{
- if (!is_string($ciphertext)) {
- throw new Horde_Secret_Exception('Chiper text must be a string', 1);
- }
-
+ $ciphertext = (string) $ciphertext;
if (strlen($key) && strlen($ciphertext)) {
return rtrim($this->_getCipherOb($key)->decrypt($ciphertext), "\0");
} else {
/**
* @expectedException Horde_Secret_Exception
*/
- public function testWriteException()
- {
- $secret = new Horde_Secret();
- $secret->write("\x88", array());
- }
-
- /**
- * @expectedException Horde_Secret_Exception
- */
- public function testReadException()
- {
- $secret = new Horde_Secret();
- $secret->read("\x88", array());
- }
-
- /**
- * @expectedException Horde_Secret_Exception
- */
public function testKeyException()
{
$secret = new Horde_Secret();