Skip to content

Commit

Permalink
Simplify number formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 23, 2012
1 parent 434d3a7 commit 2359fb7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
5 changes: 0 additions & 5 deletions 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)
*
Expand All @@ -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)
*/
Expand Down
13 changes: 5 additions & 8 deletions lib/Cake/Utility/Security.php
Expand Up @@ -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',

This comment has been minimized.

Copy link
@sitedyno

sitedyno Jul 23, 2012

Contributor

Aaah I should pay more attention to printf modifiers xD

),
'saltLength' => array(
'blowfish' => 22,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 2359fb7

Please sign in to comment.