Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
37 | 2 | public static function crypt(string $input, string $key, string $algo = 'sha3-512'): string |
|
38 | { |
||
39 | 2 | $chunks = \str_split($input, Str::hashSize($algo)); |
|
40 | |||
41 | 2 | $length = Str::strlen($input); |
|
42 | |||
43 | 2 | $key = new OpensslKey($algo, $key, ''); |
|
44 | |||
45 | 2 | foreach ($chunks as $i => &$chunk) { |
|
46 | 2 | $info = $length . $i; |
|
47 | 2 | $chunk = $chunk ^ $key->deriveKey($info); |
|
48 | } |
||
49 | |||
50 | 2 | return \implode($chunks); |
|
51 | } |
||
52 | } |
||
53 |