From 3e518cc3ec4b2c1e7c432c2462d67d2feb52e803 Mon Sep 17 00:00:00 2001 From: Ivar van der Burg Date: Wed, 29 Jul 2015 15:40:37 +0200 Subject: [PATCH] Unit test salts --- tests/AngryBytes/Hash/Test/BlowfishTest.php | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/AngryBytes/Hash/Test/BlowfishTest.php b/tests/AngryBytes/Hash/Test/BlowfishTest.php index 8960f71..d1c0504 100644 --- a/tests/AngryBytes/Hash/Test/BlowfishTest.php +++ b/tests/AngryBytes/Hash/Test/BlowfishTest.php @@ -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 *