Commit 80f810de by Taylor Otwell

refactoring the crypter class.

parent 8d3151b1
......@@ -19,7 +19,7 @@ class Crypter {
*
* @var string
*/
protected static $mode = 'cbc';
protected static $mode = MCRYPT_MODE_CBC;
/**
* Encrypt a string using Mcrypt.
......@@ -37,7 +37,7 @@ class Crypter {
*/
public static function encrypt($value)
{
$iv = mcrypt_create_iv(static::iv_size(), static::randomizer());
$iv = mcrypt_create_iv(static::iv_size(), MCRYPT_RAND);
$value = mcrypt_encrypt(static::$cipher, static::key(), $value, static::$mode, $iv);
......@@ -45,23 +45,6 @@ class Crypter {
}
/**
* Get the random number generator appropriate for the server.
*
* There are a variety of sources to get a random number; however, not all
* of them will be available on every server. We will attempt to use the
* most secure random number generator available.
*
* @return int
*/
protected static function randomizer()
{
foreach (array('MCRYPT_DEV_URANDOM', 'MCRYPT_DEV_RANDOM', 'MCRYPT_RAND') as $generator)
{
if (defined($generator)) return constant($generator);
}
}
/**
* Decrypt a string using Mcrypt.
*
* @param string $value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment