/** * test password hashing * * @return void */ public function testPassword() { $result = DigestAuthenticate::password('mark', 'password', 'localhost'); $expected = md5('mark:localhost:password'); $this->assertEquals($expected, $result); }
public function beforeSave(Event $event) { $entity = $event->data['entity']; // Make a password for digest auth. $entity->digest_hash = DigestAuthenticate::password($entity->username, 'Rho9Sigma', env('SERVER_NAME')); if ($entity->authrole === 'admin') { $hasher = new DefaultPasswordHasher(); // Generate an API 'token' $entity->api_key_plain = sha1(Text::uuid()); // Bcrypt the token so BasicAuthenticate can check // it during login. $entity->api_key = $hasher->hash($entity->api_key_plain); } return true; }