| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 32 | public function setSecretKey($key) |
||
| 33 | { |
||
| 34 | if (!is_string($key)) { |
||
|
1 ignored issue
–
show
|
|||
| 35 | throw new \InvalidArgumentException('The secret key must be a string or a binary string.'); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * {@internal The encryption standard is 8-bit wise (don not use StringBuilder) and utilizes performance. }} |
||
| 40 | */ |
||
| 41 | if (strlen($key) > static::KEY_SIZE) { |
||
|
1 ignored issue
–
show
|
|||
| 42 | $key = hash_hkdf('sha256', $key, static::KEY_SIZE, 'CryptoMañana', ''); |
||
| 43 | } elseif (strlen($key) < static::KEY_SIZE) { |
||
| 44 | $key = str_pad($key, static::KEY_SIZE, "\x0", STR_PAD_RIGHT); |
||
| 45 | } |
||
| 46 | |||
| 47 | $this->key = $key; |
||
| 48 | |||
| 49 | return $this; |
||
| 50 | } |
||
| 62 |