Skip to content
This repository
Browse code

Simplify number formatting.

  • Loading branch information...
commit 2359fb7e2efec50b113870298fd4847a4b1528ef 1 parent 434d3a7
Mark Story authored July 22, 2012
5  lib/Cake/Test/Case/Utility/SecurityTest.php
... ...
@@ -1,9 +1,5 @@
1 1
 <?php
2 2
 /**
3  
- * SecurityTest file
4  
- *
5  
- * PHP 5
6  
- *
7 3
  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
8 4
  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
9 5
  *
@@ -12,7 +8,6 @@
12 8
  *
13 9
  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
14 10
  * @link          http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
15  
- * @package       Cake.Test.Case.Utility
16 11
  * @since         CakePHP(tm) v 1.2.0.5432
17 12
  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
18 13
  */
13  lib/Cake/Utility/Security.php
@@ -235,7 +235,7 @@ public static function salt($length = 22) {
235 235
 	protected static function _crypt($password, $type = null, $salt = false) {
236 236
 		$options = array(
237 237
 			'saltFormat' => array(
238  
-				'blowfish' => '$2a$%s$%s',
  238
+				'blowfish' => '$2a$%02d$%s',
239 239
 			),
240 240
 			'saltLength' => array(
241 241
 				'blowfish' => 22,
@@ -264,14 +264,11 @@ protected static function _crypt($password, $type = null, $salt = false) {
264 264
 				), E_USER_WARNING);
265 265
 				return '';
266 266
 			}
267  
-			$vspArgs = array();
268 267
 			$salt = self::salt($saltLength[$hashType]);
269  
-			if ($hashType === 'blowfish') {
270  
-				$bfCost = chr(ord('0') + $cost / 10);
271  
-				$bfCost .= chr(ord('0') + $cost % 10);
272  
-				$vspArgs[] = $bfCost;
273  
-			}
274  
-			$vspArgs[] = $salt;
  268
+			$vspArgs = array(
  269
+				$cost,
  270
+				$salt,
  271
+			);
275 272
 			$salt = vsprintf($saltFormat[$hashType], $vspArgs);
276 273
 		} elseif ($salt === true || strpos($salt, '$2a$') !== 0 || strlen($salt) < 29) {
277 274
 			trigger_error(__d(

0 notes on commit 2359fb7

sitedyno

Aaah I should pay more attention to printf modifiers xD

Please sign in to comment.
Something went wrong with that request. Please try again.