selfsimilar / drupal7_password_hasher
封装在正确命名空间中的类的Drupal 7密码散列器。
v1.0.0
2020-11-03 00:00 UTC
Requires
- php: >=7.0.0
Requires (Dev)
- phpunit/phpunit: ^9
README
这是Drupal 7密码散列器代码,已重新格式化为PSR-4兼容的库类,用于需要导入旧版Drupal 7用户账户的PHP项目。Drupal 7许可协议为GPLv3,由于此代码直接借鉴了该代码,因此我也以类似的方式许可此代码。感谢HauteLook提供的Modernized Openwall Phpass包的灵感。
用法
<?php namespace Your\Namespace; use Selfsimilar\D7PasswordHasher\Hasher; require_once(__DIR__ . "/vendor/autoload.php"); // Constructor take the iteration count for number of cycles to hash, but by // default uses the Drupal 7 stock number. You may need to check your Drupal 7 // installation for the value of `password_count_log2` (e.g. `drush // variable-get password_count_log2`). If it is set and different than 15, // you will need to pass it to the Hasher() constructor. $passwordHasher = new Hasher(); $password = $passwordHasher->HashPassword('secret'); var_dump($password); $passwordMatch = $passwordHasher->CheckPassword('secret', "$2a$08$0RK6Yw6j9kSIXrrEOc3dwuDPQuT78HgR0S3/ghOFDEpOGpOkARoSu"); var_dump($passwordMatch);