コード例 #1
0
 public function safeUp()
 {
     Yii::import('common.extensions.behaviors.password.*');
     $bcrypt = new ABcryptPasswordStrategy();
     $this->insert('user', array('username' => 'admin', 'email' => '*****@*****.**', 'password' => $bcrypt->encode('smart_password'), 'salt' => $bcrypt->getSalt(), 'password_strategy' => 'bcrypt'));
     $this->insert('user', array('username' => 'demo', 'email' => '*****@*****.**', 'password' => $bcrypt->encode('strong_password'), 'salt' => $bcrypt->getSalt(), 'password_strategy' => 'bcrypt'));
 }
コード例 #2
0
 public function testEncode()
 {
     $strategy = new ABcryptPasswordStrategy();
     $strategy->getSalt(true);
     $password = "******";
     $this->assertFalse($strategy->compare("test", $strategy->encode($password)));
     $this->assertTrue($strategy->compare("qwerty1", $strategy->encode($password)));
 }