Skip to content

Commit

Permalink
Unit test salts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivar van der Burg committed Jul 29, 2015
1 parent d7f5af7 commit 3e518cc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/AngryBytes/Hash/Test/BlowfishTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,29 @@ public function testWorkFactor()
);
}

/**
* Test salting
**/
public function testSalt()
{
$hasher = $this->createHasher();
$hasher->getHasher()->setWorkFactor(5);

// Test salt with 22 valid characters
$this->assertEquals(
// Pre-generated hash outcome for password 'foo' and given salt
'$2y$05$./A1aaaaaaaaaaaaaaaaaOZW9OJaO6Alj4.ZDbOi6Jrbn.bGZfYRK',
$hasher->getHasher()->hash('foo', './A1aaaaaaaaaaaaaaaaaa')
);

// Test salt with less invalid characters
$this->assertEquals(
// Pre-generated hash outcome for password 'foo' and given salt (md5'ed)
'$2y$05$ceb20772e0c9d240c75ebugm2AOmnuR5.LsdpDZGAjkE1DupDTPFW',
$hasher->getHasher()->hash('foo', 'salt')
);
}

/**
* Create hasher
*
Expand Down

0 comments on commit 3e518cc

Please sign in to comment.