Total Complexity | 11 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
7 | class Resource |
||
8 | { |
||
9 | use TraitCryption; |
||
10 | |||
11 | private int $length; |
||
12 | private string $iv; |
||
13 | private string $key; |
||
14 | private string $dKey; |
||
15 | private string $data; |
||
16 | |||
17 | public function __construct() |
||
18 | { |
||
19 | $this->setLength(); |
||
20 | $this->setIv(); |
||
21 | $this->setDKey(); |
||
22 | $this->setKey(); |
||
23 | } |
||
24 | |||
25 | private function getLength(): int |
||
26 | { |
||
27 | return $this->length; |
||
28 | } |
||
29 | |||
30 | private function setLength(): void |
||
31 | { |
||
32 | $this->length = openssl_cipher_iv_length(CRYPTION_CIPHERING); |
||
33 | } |
||
34 | |||
35 | private function getIv(): string |
||
36 | { |
||
37 | return $this->iv; |
||
38 | } |
||
39 | |||
40 | private function setIv(): void |
||
41 | { |
||
42 | $this->iv = random_bytes($this->getLength()); |
||
43 | } |
||
44 | |||
45 | private function getKey(): string |
||
46 | { |
||
47 | return $this->key; |
||
48 | } |
||
49 | |||
50 | private function setKey(): void |
||
51 | { |
||
52 | $this->key = CRYPTION_KEY . $this->getDKey(); |
||
53 | } |
||
54 | |||
55 | |||
56 | private function getDKey(): string |
||
57 | { |
||
58 | return $this->dKey; |
||
59 | } |
||
60 | |||
61 | private function setDKey(): void |
||
62 | { |
||
63 | $this->dKey = openssl_digest(php_uname(), 'MD5', TRUE); |
||
64 | } |
||
65 | |||
66 | protected function getData(): string |
||
69 | } |
||
70 | |||
71 | protected function setData(string $string): void |
||
75 | } |
||
76 | } |
||
77 |