refactoring.

This commit is contained in:
Taylor Otwell
2011-11-01 19:41:35 -05:00
parent c3c0fbce96
commit 83d927c4f1
11 changed files with 52 additions and 40 deletions

View File

@@ -65,22 +65,13 @@ class Crypter {
throw new \Exception('Decryption error. Input value is not valid base64 data.');
}
list($iv, $value) = static::parse($value);
$iv = substr($value, 0, static::iv_size());
$value = substr($value, static::iv_size());
return rtrim(mcrypt_decrypt(static::$cipher, static::key(), $value, static::$mode, $iv), "\0");
}
/**
* Parse an encrypted string into its input vector and value segments.
*
* @param string $value
* @return array
*/
protected static function parse($value)
{
return array(substr($value, 0, static::iv_size()), substr($value, static::iv_size()));
}
/**
* Get the input vector size for the cipher and mode.
*