@@ -28,65 +28,65 @@ protected function setUp(): void
2828 public function testValidation ()
2929 {
3030 $ hasher = new SodiumPasswordHasher ();
31- $ result = $ hasher ->hash ('password ' , null );
32- $ this ->assertTrue ($ hasher ->verify ($ result , 'password ' , null ));
33- $ this ->assertFalse ($ hasher ->verify ($ result , 'anotherPassword ' , null ));
34- $ this ->assertFalse ($ hasher ->verify ($ result , '' , null ));
31+ $ result = $ hasher ->hash ('password ' );
32+ $ this ->assertTrue ($ hasher ->verify ($ result , 'password ' ));
33+ $ this ->assertFalse ($ hasher ->verify ($ result , 'anotherPassword ' ));
34+ $ this ->assertFalse ($ hasher ->verify ($ result , '' ));
3535 }
3636
3737 public function testBcryptValidation ()
3838 {
3939 $ hasher = new SodiumPasswordHasher ();
40- $ this ->assertTrue ($ hasher ->verify ('$2y$04$M8GDODMoGQLQRpkYCdoJh.lbiZPee3SZI32RcYK49XYTolDGwoRMm ' , 'abc ' , null ));
40+ $ this ->assertTrue ($ hasher ->verify ('$2y$04$M8GDODMoGQLQRpkYCdoJh.lbiZPee3SZI32RcYK49XYTolDGwoRMm ' , 'abc ' ));
4141 }
4242
4343 public function testNonArgonValidation ()
4444 {
4545 $ hasher = new SodiumPasswordHasher ();
46- $ this ->assertTrue ($ hasher ->verify ('$5$abcdefgh$ZLdkj8mkc2XVSrPVjskDAgZPGjtj1VGVaa1aUkrMTU/ ' , 'password ' , null ));
47- $ this ->assertFalse ($ hasher ->verify ('$5$abcdefgh$ZLdkj8mkc2XVSrPVjskDAgZPGjtj1VGVaa1aUkrMTU/ ' , 'anotherPassword ' , null ));
48- $ this ->assertTrue ($ hasher ->verify ('$6$abcdefgh$yVfUwsw5T.JApa8POvClA1pQ5peiq97DUNyXCZN5IrF.BMSkiaLQ5kvpuEm/VQ1Tvh/KV2TcaWh8qinoW5dhA1 ' , 'password ' , null ));
49- $ this ->assertFalse ($ hasher ->verify ('$6$abcdefgh$yVfUwsw5T.JApa8POvClA1pQ5peiq97DUNyXCZN5IrF.BMSkiaLQ5kvpuEm/VQ1Tvh/KV2TcaWh8qinoW5dhA1 ' , 'anotherPassword ' , null ));
46+ $ this ->assertTrue ($ hasher ->verify ('$5$abcdefgh$ZLdkj8mkc2XVSrPVjskDAgZPGjtj1VGVaa1aUkrMTU/ ' , 'password ' ));
47+ $ this ->assertFalse ($ hasher ->verify ('$5$abcdefgh$ZLdkj8mkc2XVSrPVjskDAgZPGjtj1VGVaa1aUkrMTU/ ' , 'anotherPassword ' ));
48+ $ this ->assertTrue ($ hasher ->verify ('$6$abcdefgh$yVfUwsw5T.JApa8POvClA1pQ5peiq97DUNyXCZN5IrF.BMSkiaLQ5kvpuEm/VQ1Tvh/KV2TcaWh8qinoW5dhA1 ' , 'password ' ));
49+ $ this ->assertFalse ($ hasher ->verify ('$6$abcdefgh$yVfUwsw5T.JApa8POvClA1pQ5peiq97DUNyXCZN5IrF.BMSkiaLQ5kvpuEm/VQ1Tvh/KV2TcaWh8qinoW5dhA1 ' , 'anotherPassword ' ));
5050 }
5151
5252 public function testHashLength ()
5353 {
5454 $ this ->expectException (InvalidPasswordException::class);
5555 $ hasher = new SodiumPasswordHasher ();
56- $ hasher ->hash (str_repeat ('a ' , 4097 ), ' salt ' );
56+ $ hasher ->hash (str_repeat ('a ' , 4097 ));
5757 }
5858
5959 public function testCheckPasswordLength ()
6060 {
6161 $ hasher = new SodiumPasswordHasher ();
62- $ result = $ hasher ->hash (str_repeat ('a ' , 4096 ), null );
63- $ this ->assertFalse ($ hasher ->verify ($ result , str_repeat ('a ' , 4097 ), null ));
64- $ this ->assertTrue ($ hasher ->verify ($ result , str_repeat ('a ' , 4096 ), null ));
62+ $ result = $ hasher ->hash (str_repeat ('a ' , 4096 ));
63+ $ this ->assertFalse ($ hasher ->verify ($ result , str_repeat ('a ' , 4097 )));
64+ $ this ->assertTrue ($ hasher ->verify ($ result , str_repeat ('a ' , 4096 )));
6565 }
6666
6767 public function testBcryptWithLongPassword ()
6868 {
69- $ hasher = new SodiumPasswordHasher (null , null , 4 );
69+ $ hasher = new SodiumPasswordHasher (null , null );
7070 $ plainPassword = str_repeat ('a ' , 100 );
7171
72- $ this ->assertFalse ($ hasher ->verify (password_hash ($ plainPassword , \PASSWORD_BCRYPT , ['cost ' => 4 ]), $ plainPassword, ' salt ' ));
73- $ this ->assertTrue ($ hasher ->verify ((new NativePasswordHasher (null , null , 4 , \PASSWORD_BCRYPT ))->hash ($ plainPassword ), $ plainPassword, ' salt ' ));
72+ $ this ->assertFalse ($ hasher ->verify (password_hash ($ plainPassword , \PASSWORD_BCRYPT , ['cost ' => 4 ]), $ plainPassword ));
73+ $ this ->assertTrue ($ hasher ->verify ((new NativePasswordHasher (null , null , 4 , \PASSWORD_BCRYPT ))->hash ($ plainPassword ), $ plainPassword ));
7474 }
7575
7676 public function testBcryptWithNulByte ()
7777 {
78- $ hasher = new SodiumPasswordHasher (null , null , 4 );
78+ $ hasher = new SodiumPasswordHasher (null , null );
7979 $ plainPassword = "a \0b " ;
8080
81- $ this ->assertFalse ($ hasher ->verify (password_hash ($ plainPassword , \PASSWORD_BCRYPT , ['cost ' => 4 ]), $ plainPassword, ' salt ' ));
82- $ this ->assertTrue ($ hasher ->verify ((new NativePasswordHasher (null , null , 4 , \PASSWORD_BCRYPT ))->hash ($ plainPassword ), $ plainPassword, ' salt ' ));
81+ $ this ->assertFalse ($ hasher ->verify (password_hash ($ plainPassword , \PASSWORD_BCRYPT , ['cost ' => 4 ]), $ plainPassword ));
82+ $ this ->assertTrue ($ hasher ->verify ((new NativePasswordHasher (null , null , 4 , \PASSWORD_BCRYPT ))->hash ($ plainPassword ), $ plainPassword ));
8383 }
8484
8585 public function testUserProvidedSaltIsNotUsed ()
8686 {
8787 $ hasher = new SodiumPasswordHasher ();
88- $ result = $ hasher ->hash ('password ' , ' salt ' );
89- $ this ->assertTrue ($ hasher ->verify ($ result , 'password ' , ' anotherSalt ' ));
88+ $ result = $ hasher ->hash ('password ' );
89+ $ this ->assertTrue ($ hasher ->verify ($ result , 'password ' ));
9090 }
9191
9292 public function testNeedsRehash ()
@@ -95,7 +95,7 @@ public function testNeedsRehash()
9595
9696 $ this ->assertTrue ($ hasher ->needsRehash ('dummyhash ' ));
9797
98- $ hash = $ hasher ->hash ('foo ' , ' salt ' );
98+ $ hash = $ hasher ->hash ('foo ' );
9999 $ this ->assertFalse ($ hasher ->needsRehash ($ hash ));
100100
101101 $ hasher = new SodiumPasswordHasher (5 , 11000 );
0 commit comments