Skip to content

Commit 2e0534b

Browse files
authored
Merge pull request #13 from olssonm/dev
Update for #12
2 parents f1b74e0 + 341a596 commit 2e0534b

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

README.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
A simple implementation of zxcvbn for Laravel 5. This package allows you to access "zxcvbn-related" data on a passphrase in the application and also to use zxcvbn as a standard validator.
1212

13-
Uses [Zxcvbn-PHP](https://github.com/bjeavons/zxcvbn-php) by [@bjeavons](https://github.com/bjeavons), which in turn is inspired by [zxcvbn](https://github.com/dropbox/zxcvbn) by [@dropbox](https://github.com/dropbox).
13+
Uses [Zxcvbn-PHP](https://github.com/mkopinsky/zxcvbn-php) by [@mkopinsky](https://github.com/mkopinsky) (originally by [@bjeavons](https://github.com/bjeavons)), which in turn is inspired by [zxcvbn](https://github.com/dropbox/zxcvbn) by [@dropbox](https://github.com/dropbox).
1414

1515
## Install
1616

@@ -54,17 +54,19 @@ class MyClass extends MyOtherClass
5454
$zxcvbn = Zxcvbn::passwordStrength('password');
5555
dd($zxcvbn);
5656

57-
// array:6 [▼
58-
// "crack_time" => 5.0E-5
59-
// "calc_time" => 0.12961101531982
60-
// "password" => "password"
61-
// "entropy" => 0.0
62-
// "match_sequence" => array:1 []
63-
// "score" => 0
57+
// array:9 [
58+
// "password" => "password"
59+
// "guesses" => 3
60+
// "guesses_log10" => 0.47712125471966
61+
// "sequence" => array:1 []
62+
// "crack_times_seconds" => array:4 []
63+
// "crack_times_display" => array:4 []
64+
// "score" => 0
65+
// "feedback" => array:2 []
66+
// "calc_time" => 0.042769908905029
6467
// ]
6568
}
6669
}
67-
?>
6870
```
6971

7072
Play around with different passwords and phrases, the results may surprise you. Check out [Zxcvbn-PHP](https://github.com/bjeavons/zxcvbn-php) for more uses and examples.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require": {
2323
"php" : ">=7.1.3",
2424
"illuminate/support": "^5.8",
25-
"bjeavons/zxcvbn-php": "0.4.0"
25+
"mkopinsky/zxcvbn-php": "^4.4"
2626
},
2727
"require-dev": {
2828
"phpunit/phpunit" : "~7.0",

src/ZxcvbnServiceProvider.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function boot()
5050
$zxcvbn = new ZxcvbnPhp();
5151
$zxcvbn = $zxcvbn->passwordStrength($value, [$username, $email]);
5252

53-
if (isset($zxcvbn['match_sequence'][0])) {
54-
$dictionary = $zxcvbn['match_sequence'][0];
53+
if (isset($zxcvbn['sequence'][0])) {
54+
$dictionary = $zxcvbn['sequence'][0];
5555
if (isset($dictionary->dictionaryName)) {
5656
return false;
5757
}
@@ -74,7 +74,7 @@ public function boot()
7474
*/
7575
public function register()
7676
{
77-
$this->app->bind('zxcvbn', function($app) {
77+
$this->app->bind('zxcvbn', function() {
7878
return new ZxcvbnPhp();
7979
});
8080
}

tests/ZxcvbnTest.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ protected function getPackageAliases($app)
3838
*/
3939
public function test_zxcvbn_basics()
4040
{
41+
$zxcvbn = Zxcvbn::passwordStrength('password');
42+
4143
$testVar1 = Zxcvbn::passwordStrength('test');
4244

4345
// Check keys
4446
$this->assertArrayHasKey('score', $testVar1);
45-
$this->assertArrayHasKey('match_sequence', $testVar1);
46-
$this->assertArrayHasKey('entropy', $testVar1);
47-
$this->assertArrayHasKey('password', $testVar1);
47+
$this->assertArrayHasKey('sequence', $testVar1);
48+
$this->assertArrayHasKey('crack_times_seconds', $testVar1);
49+
$this->assertArrayHasKey('crack_times_display', $testVar1);
4850
$this->assertArrayHasKey('calc_time', $testVar1);
49-
$this->assertArrayHasKey('crack_time', $testVar1);
51+
$this->assertArrayHasKey('guesses', $testVar1);
5052

5153
// Check score-value
5254
$this->assertEquals(0, $testVar1['score']);
@@ -57,7 +59,7 @@ public function test_zxcvbn_basics()
5759
$testVar4 = Zxcvbn::passwordStrength('7E6k9axB*gwGHa&aZTohmD9Wr&NVs[b4'); //<-- 32
5860

5961
// Check score-value
60-
$this->assertEquals(1, $testVar2['score']);
62+
$this->assertEquals(2, $testVar2['score']);
6163
$this->assertEquals(4, $testVar3['score']);
6264
$this->assertEquals(4, $testVar4['score']);
6365
}
@@ -106,6 +108,7 @@ public function test_password_dictionary_with_message()
106108
$this->assertEquals('Just a message', $this->validate_with_message_dictionary('test', '[email protected]', 'test', 'Just a message'));
107109
}
108110

111+
/** @note validation helper */
109112
private function validate_without_message_min($password, $min)
110113
{
111114
$data = ['password' => $password];
@@ -116,6 +119,7 @@ private function validate_without_message_min($password, $min)
116119
return $validator->passes();
117120
}
118121

122+
/** @note validation helper */
119123
private function validate_with_message_min($password, $min, $message)
120124
{
121125
$data = ['password' => $password];
@@ -129,6 +133,7 @@ private function validate_with_message_min($password, $min, $message)
129133
return $errors->first('password');
130134
}
131135

136+
/** @note validation helper */
132137
private function validate_without_message_dictionary($password, $email, $username)
133138
{
134139
$data = ['password' => $password];
@@ -139,6 +144,7 @@ private function validate_without_message_dictionary($password, $email, $usernam
139144
return $validator->passes();
140145
}
141146

147+
/** @note validation helper */
142148
private function validate_with_message_dictionary($password, $email, $username, $message)
143149
{
144150
$data = ['password' => $password];

0 commit comments

Comments
 (0)