Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify number formatting.

  • Loading branch information...
commit 2359fb7e2efec50b113870298fd4847a4b1528ef 1 parent 434d3a7
@markstory markstory authored
View
5 lib/Cake/Test/Case/Utility/SecurityTest.php
@@ -1,9 +1,5 @@
<?php
/**
- * SecurityTest file
- *
- * PHP 5
- *
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -12,7 +8,6 @@
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
- * @package Cake.Test.Case.Utility
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
View
13 lib/Cake/Utility/Security.php
@@ -235,7 +235,7 @@ public static function salt($length = 22) {
protected static function _crypt($password, $type = null, $salt = false) {
$options = array(
'saltFormat' => array(
- 'blowfish' => '$2a$%s$%s',
+ 'blowfish' => '$2a$%02d$%s',

Aaah I should pay more attention to printf modifiers xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
),
'saltLength' => array(
'blowfish' => 22,
@@ -264,14 +264,11 @@ protected static function _crypt($password, $type = null, $salt = false) {
), E_USER_WARNING);
return '';
}
- $vspArgs = array();
$salt = self::salt($saltLength[$hashType]);
- if ($hashType === 'blowfish') {
- $bfCost = chr(ord('0') + $cost / 10);
- $bfCost .= chr(ord('0') + $cost % 10);
- $vspArgs[] = $bfCost;
- }
- $vspArgs[] = $salt;
+ $vspArgs = array(
+ $cost,
+ $salt,
+ );
$salt = vsprintf($saltFormat[$hashType], $vspArgs);
} elseif ($salt === true || strpos($salt, '$2a$') !== 0 || strlen($salt) < 29) {
trigger_error(__d(
Please sign in to comment.
Something went wrong with that request. Please try again.