Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
ApiUtility | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
generateKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
generateSecret | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Domain; |
6 | |
7 | use PeServer\App\Models\AppConfiguration; |
8 | use PeServer\App\Models\AppCryptography; |
9 | use PeServer\Core\Cryptography; |
10 | |
11 | abstract class ApiUtility |
12 | { |
13 | private const API_KEY_LENGTH = 64; |
14 | private const SECRET_LENGTH = 256; |
15 | private const HTTP_HEAD_STRING = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_!-~^|[],.'; |
16 | |
17 | public static function generateKey(): string |
18 | { |
19 | return Cryptography::generateRandomString(self::API_KEY_LENGTH, self::HTTP_HEAD_STRING); |
20 | } |
21 | |
22 | public static function generateSecret(): string |
23 | { |
24 | return Cryptography::generateRandomString(self::SECRET_LENGTH, self::HTTP_HEAD_STRING); |
25 | } |
26 | } |