| Conditions | 3 |
| Paths | 3 |
| Total Lines | 11 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | 11 | public function derive(string $password, string $salt, int $count, |
|
| 37 | int $length): string |
||
| 38 | { |
||
| 39 | 11 | if ($length > $this->_hashFunc->length()) { |
|
| 40 | 1 | throw new \LogicException('Derived key too long.'); |
|
| 41 | } |
||
| 42 | 10 | $key = $password . $salt; |
|
| 43 | 10 | for ($i = 0; $i < $count; ++$i) { |
|
| 44 | 10 | $key = $this->_hashFunc->__invoke($key); |
|
| 45 | } |
||
| 46 | 10 | return substr($key, 0, $length); |
|
| 47 | } |
||
| 49 |