| Total Complexity | 3 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class KeyGenerationService |
||
| 16 | { |
||
| 17 | public const DIGEST_ALGORITHM = 'sha256'; |
||
| 18 | private const KEY_LENGTH = 2048; |
||
| 19 | |||
| 20 | public function extractPublicKey(string $privateKey): string |
||
| 21 | { |
||
| 22 | $res = \openssl_pkey_get_private($privateKey); |
||
| 23 | |||
| 24 | if (false === $res) { |
||
| 25 | throw new LogicException('Cannot read private key.'); |
||
| 26 | } |
||
| 27 | |||
| 28 | return \openssl_pkey_get_details($res)['key']; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function createKeyPair(): KeyPair |
||
| 45 | } |
||
| 46 | } |
||
| 47 |