Total Complexity | 3 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
17 | class SecureIDEncoder extends SimpleIDEncoder |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $secret; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $nonce; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $cipher = "aes-128-ctr"; |
||
33 | |||
34 | /** |
||
35 | * @param DefinitionRegistry $definitionRegistry |
||
36 | * @param Registry $registry |
||
37 | * @param string $secret |
||
38 | */ |
||
39 | public function __construct(DefinitionRegistry $definitionRegistry, Registry $registry, $secret) |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * {@inheritDoc} |
||
49 | */ |
||
50 | public function encode(NodeInterface $node): ?string |
||
51 | { |
||
52 | $nodeString = parent::encode($node); |
||
53 | $ciphertext = openssl_encrypt( |
||
54 | $nodeString, |
||
55 | $this->cipher, |
||
56 | $this->secret, |
||
57 | OPENSSL_ZERO_PADDING, |
||
58 | $this->nonce |
||
59 | ); |
||
60 | |||
61 | return $ciphertext; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * {@inheritDoc} |
||
66 | */ |
||
67 | public function decode($globalId): ?NodeInterface |
||
78 | } |
||
79 | } |
||
80 |