PHP code example of crumbls / common-passwords

1. Go to this page and download the library: Download crumbls/common-passwords library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

crumbls / common-passwords example snippets


try {
    $validator = \Illuminate\Support\Facades\Validator::make([
        'password' => 'password'
    ], [
        'password' => [
            ' ]);
    print_r($validator->validated());
} catch (\Illuminate\Validation\ValidationException $e) {
    echo $e->getMessage();
}

 /**
     * Get a validator for an incoming registration request.
     *
     * @param  array $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['

// Take a random user.  You should be more pointed than this.
$user = \App\Models\User::inRandomOrder()->take(1)->first();
    $passwords = \Crumbls\CommonPasswords\Models\Password::orderBy(
        with(new \Crumbls\CommonPasswords\Models\Password())->getKeyName(),
        'asc'
    )->get();
    foreach($passwords as $password) {
        if (\Hash::check($password->password, $user->password)) {
            printf('User had an invalid password: %s .', $password->password);
            break;
        }
    }