Skip to content

Commit

Permalink
Base64 encode output to make it consistent with the other mechanisms.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaiahdw committed Jan 21, 2011
1 parent 2cc2be4 commit 103d624
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions classes/bonafide/mechanism/pbkdf2.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function hash($password, $salt = NULL, $iterations = NULL)
*
* @param string input text
* @param string appended salt
* @return binary
* @return string base64 encoded derived key
*/
protected function _hash($input, $salt = NULL)
{
Expand All @@ -88,8 +88,8 @@ protected function _hash($input, $salt = NULL)
$output .= $ib;
}

// Binary output
return substr($output, 0, $this->length);
// Base64 encode output to make storage easier
return base64_encode(substr($output, 0, $this->length));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/bonafide/Pbkdf2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function provider_pbkdf2()
* @param int $key_length Key length
* @param string $expected Expected value
*/
public function test_bbkdf2($password, $salt, $iterations, $key_length, $expected)
public function test_pbkdf2($password, $salt, $iterations, $key_length, $expected)
{
$config = array(
'type' => 'sha1',
Expand All @@ -52,6 +52,6 @@ public function test_bbkdf2($password, $salt, $iterations, $key_length, $expecte

$hash = Bonafide::mechanism('PBKDF2', $config)->hash($password, $salt);

$this->assertSame(bin2hex($hash), $expected);
$this->assertSame(bin2hex(base64_decode($hash)), $expected);
}
}

0 comments on commit 103d624

Please sign in to comment.