Skip to content

Commit 2359fb7

Browse files
committed
Simplify number formatting.
1 parent 434d3a7 commit 2359fb7

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

lib/Cake/Test/Case/Utility/SecurityTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22
/**
3-
* SecurityTest file
4-
*
5-
* PHP 5
6-
*
73
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
84
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
95
*
@@ -12,7 +8,6 @@
128
*
139
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
1410
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
15-
* @package Cake.Test.Case.Utility
1611
* @since CakePHP(tm) v 1.2.0.5432
1712
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1813
*/

lib/Cake/Utility/Security.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public static function salt($length = 22) {
235235
protected static function _crypt($password, $type = null, $salt = false) {
236236
$options = array(
237237
'saltFormat' => array(
238-
'blowfish' => '$2a$%s$%s',
238+
'blowfish' => '$2a$%02d$%s',
239239
),
240240
'saltLength' => array(
241241
'blowfish' => 22,
@@ -264,14 +264,11 @@ protected static function _crypt($password, $type = null, $salt = false) {
264264
), E_USER_WARNING);
265265
return '';
266266
}
267-
$vspArgs = array();
268267
$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+
);
275272
$salt = vsprintf($saltFormat[$hashType], $vspArgs);
276273
} elseif ($salt === true || strpos($salt, '$2a$') !== 0 || strlen($salt) < 29) {
277274
trigger_error(__d(

0 commit comments

Comments
 (0)