好的 / 安全
适用于Nice应用程序的简单安全组件
1.0.0
2014-12-11 00:33 UTC
Requires
- php: >=5.4.0
- ircmaxell/password-compat: ~1.0
- symfony/config: ~2.3
- symfony/dependency-injection: ~2.3
- symfony/http-kernel: ~2.3
Requires (Dev)
- nice/framework: 1.0.x-dev
- phpunit/phpunit: ~3.7
This package is auto-updated.
Last update: 2024-09-25 05:27:00 UTC
README
适用于Nice应用程序的简单安全组件。
安装
使用 Composer 安装 nice/security 包。
从您的项目根目录运行
composer require nice/security:1.0.x-dev
此命令会将 nice/security 包添加到您的 composer.json
文件,然后安装必要的文件。
用法
nice/security 包包含一个默认认证器,Nice\Security\Authenticator\SimpleAuthenticator
。此认证器使用PHP 5.5的password_* API,并在PHP 5.4上回退到ircmaxell的password_compat库。
在使用 nice/security 之前,您必须对密码进行散列。这可以通过包含的hashpass.php
实用程序完成。
hashpass.php
的完整源代码
<?php (@include_once __DIR__ . '/../vendor/autoload.php') || @include_once __DIR__ . '/../../../autoload.php'; $in = fopen('php://stdin', 'r'); echo "Enter password to hash: "; $pass = fgets($in); // trim newline $pass = substr($pass, 0, strlen($pass) - 1); $hash = password_hash($pass, PASSWORD_DEFAULT); echo "Hashed result:\n"; echo $hash."\n\n";
此实用程序将通过Composer自动安装到您的vendor/bin
目录。
运行它
vendor/bin/hashpass