1. Go to this page and download the library: Download phpnode/yiipassword 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/ */
phpnode / yiipassword example snippets
class User extends CActiveRecord
{
public function behaviors()
{
return array(
"PasswordBehavior" => array(
"class" => "YiiPassword\Behavior",
"defaultStrategyName" => "bcrypt",
"strategies" => array(
"bcrypt" => array(
"class" => "YiiPassword\Strategies\Bcrypt",
"workFactor" => 14
),
"legacy" => array(
"class" => "YiiPassword\Strategies\LegacyMd5",
)
),
)
);
}
....
}
$user = User::model()->findByPK(1); // a user using the legacy password strategy
echo $user->password; // unsalted md5, horrible
$user->verifyPassword("password"); // verifies the password using the legacy strategy, and rehashes based on bcrypt strategy
echo $user->password; // now hashed with bcrpt
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.