@@ -28,65 +28,65 @@ protected function setUp(): void
28
28
public function testValidation ()
29
29
{
30
30
$ 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 , '' ));
35
35
}
36
36
37
37
public function testBcryptValidation ()
38
38
{
39
39
$ hasher = new SodiumPasswordHasher ();
40
- $ this ->assertTrue ($ hasher ->verify ('$2y$04$M8GDODMoGQLQRpkYCdoJh.lbiZPee3SZI32RcYK49XYTolDGwoRMm ' , 'abc ' , null ));
40
+ $ this ->assertTrue ($ hasher ->verify ('$2y$04$M8GDODMoGQLQRpkYCdoJh.lbiZPee3SZI32RcYK49XYTolDGwoRMm ' , 'abc ' ));
41
41
}
42
42
43
43
public function testNonArgonValidation ()
44
44
{
45
45
$ 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 ' ));
50
50
}
51
51
52
52
public function testHashLength ()
53
53
{
54
54
$ this ->expectException (InvalidPasswordException::class);
55
55
$ hasher = new SodiumPasswordHasher ();
56
- $ hasher ->hash (str_repeat ('a ' , 4097 ), ' salt ' );
56
+ $ hasher ->hash (str_repeat ('a ' , 4097 ));
57
57
}
58
58
59
59
public function testCheckPasswordLength ()
60
60
{
61
61
$ 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 )));
65
65
}
66
66
67
67
public function testBcryptWithLongPassword ()
68
68
{
69
- $ hasher = new SodiumPasswordHasher (null , null , 4 );
69
+ $ hasher = new SodiumPasswordHasher (null , null );
70
70
$ plainPassword = str_repeat ('a ' , 100 );
71
71
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 ));
74
74
}
75
75
76
76
public function testBcryptWithNulByte ()
77
77
{
78
- $ hasher = new SodiumPasswordHasher (null , null , 4 );
78
+ $ hasher = new SodiumPasswordHasher (null , null );
79
79
$ plainPassword = "a \0b " ;
80
80
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 ));
83
83
}
84
84
85
85
public function testUserProvidedSaltIsNotUsed ()
86
86
{
87
87
$ 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 ' ));
90
90
}
91
91
92
92
public function testNeedsRehash ()
@@ -95,7 +95,7 @@ public function testNeedsRehash()
95
95
96
96
$ this ->assertTrue ($ hasher ->needsRehash ('dummyhash ' ));
97
97
98
- $ hash = $ hasher ->hash ('foo ' , ' salt ' );
98
+ $ hash = $ hasher ->hash ('foo ' );
99
99
$ this ->assertFalse ($ hasher ->needsRehash ($ hash ));
100
100
101
101
$ hasher = new SodiumPasswordHasher (5 , 11000 );
0 commit comments