From 80f810de241e87a927ba00094626b591b98d66aa Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 20 Oct 2011 22:47:00 -0500 Subject: [PATCH] refactoring the crypter class. --- laravel/security/crypter.php | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/laravel/security/crypter.php b/laravel/security/crypter.php index 793b4527..98c24a06 100644 --- a/laravel/security/crypter.php +++ b/laravel/security/crypter.php @@ -19,7 +19,7 @@ class Crypter { * * @var string */ - protected static $mode = 'cbc'; + protected static $mode = MCRYPT_MODE_CBC; /** * Encrypt a string using Mcrypt. @@ -37,30 +37,13 @@ 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); return base64_encode($iv.$value); } - /** - * 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. *