public function hashPassword($password, $staticSalt = null)
{
$dynamicSalt = UtilityAlgorithms::generateRandomString(22, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./');
return crypt($password, '$2a$' . $this->cost . '$' . $dynamicSalt);
}
/** * @test */ public function hashAndValidatePasswordWithDifferentCostsMatch() { $strategy = new BCryptHashingStrategy(10); $otherStrategy = new BCryptHashingStrategy(6); $derivedKeyWithSalt = $otherStrategy->hashPassword('password'); $this->assertTrue($strategy->validatePassword('password', $derivedKeyWithSalt), 'Hashing strategy should validate password with different cost'); }