kevinlebrun/password.php

Helpers for password generation and validation

0.1.3 2014-03-31 12:49 UTC

This package is not auto-updated.

Last update: 2024-12-21 15:54:52 UTC


README

Build Status Coverage Status Latest Stable Version Total Downloads Scrutinizer Code Quality

Usage

Installation via composer is highly recommended.

{
    "require": {
        "kevinlebrun/password.php": "0.*"
    }
}
$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install
#!/usr/bin/env php
<?php

require __DIR__ . '/vendor/autoload.php';

$generator = new \Password\Generator;
$generator->setMinLength(8);
$generator->setNumberOfUpperCaseLetters(2);
$generator->setNumberOfNumbers(2);
$generator->setNumberOfSymbols(1);

$password = $generator->generate();
echo 'password: ' . $password . PHP_EOL;

$validator = new \Password\Validator(new \Password\StringHelper);
$validator->setMinLength(5);
$validator->setMinLowerCaseLetters(2);
$validator->setMinUpperCaseLetters(1);
$validator->setMinNumbers(1);
$validator->setMinSymbols(3);

if ($validator->isValid($password)) {
    printf('password %s is valid' . PHP_EOL, $password);
} else {
    printf('password %s is invalid' . PHP_EOL, $password);
    var_dump($validator->getErrors());
}

Test

$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install --dev
$ bin/phpunit
$ bin/phpcs --standard=phpcs.xml -p .

Contributors

License

(The MIT License)

Copyright (c) 2014 Kevin Le Brun lebrun.k@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.