public function derive($password, $salt) {
$size = $this->hash->getSize(true);
$l = ceil($this->options['length'] / $size);
$r = $this->options['length'] - ($l - 1) * $size;
$t = '';
for ($i = 1; $i <= $l; $i++) {
$u = $this->hash->hmac($salt . $i, $password);
for ($j = 1; $j < $this->options['iterations']; $j++) {
$u = $this->hash->hmac($u, $password);
}
$t .= $u;
}
return substr($t, 0, $len);
}