1 | <?php |
||
16 | trait CryptTrait |
||
17 | { |
||
18 | /** |
||
19 | * @var CryptKey |
||
20 | */ |
||
21 | protected $privateKey; |
||
22 | |||
23 | /** |
||
24 | * @var CryptKey |
||
25 | */ |
||
26 | protected $publicKey; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $encryptionKey; |
||
32 | |||
33 | /** |
||
34 | * Set path to private key. |
||
35 | * |
||
36 | * @param CryptKey $privateKey |
||
37 | */ |
||
38 | public function setPrivateKey(CryptKey $privateKey) |
||
42 | |||
43 | /** |
||
44 | * Set path to public key. |
||
45 | * |
||
46 | * @param CryptKey $publicKey |
||
47 | */ |
||
48 | public function setPublicKey(CryptKey $publicKey) |
||
52 | |||
53 | /** |
||
54 | * Encrypt data with a private key. |
||
55 | * |
||
56 | * @param string $unencryptedData |
||
57 | * |
||
58 | * @throws \LogicException |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | protected function encrypt($unencryptedData) |
||
93 | |||
94 | /** |
||
95 | * Decrypt data with a public key. |
||
96 | * |
||
97 | * @param string $encryptedData |
||
98 | * |
||
99 | * @throws \LogicException |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | protected function decrypt($encryptedData) |
||
136 | |||
137 | /** |
||
138 | * Set the encryption key |
||
139 | * |
||
140 | * @param string $key |
||
141 | */ |
||
142 | public function setEncryptionKey($key = null) |
||
146 | } |
||
147 |