1 | <?php |
||
12 | class EloquentEncryption |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var RsaKeyHandler |
||
17 | */ |
||
18 | private $handler; |
||
19 | |||
20 | /** |
||
21 | * ApplicationKey constructor. |
||
22 | */ |
||
23 | public function __construct() |
||
33 | |||
34 | /** |
||
35 | * Have any RSA keys been generated |
||
36 | * |
||
37 | * @return bool |
||
38 | */ |
||
39 | public function exists() |
||
43 | |||
44 | /** |
||
45 | * Generate a set of RSA Keys which will be used to encrypt the database fields |
||
46 | */ |
||
47 | public function makeEncryptionKeys() |
||
52 | |||
53 | /** |
||
54 | * Create a digital set of RSA keys, defaulting to 4096-bit |
||
55 | * |
||
56 | * @param string $email |
||
57 | * @return array |
||
58 | */ |
||
59 | public function createKey($email = '') |
||
67 | |||
68 | /** |
||
69 | * Helper function to ensure RSA options match for encrypting/decrypting |
||
70 | * |
||
71 | * @param $key |
||
72 | * @return RSA |
||
73 | */ |
||
74 | private function getRsa($key) |
||
82 | |||
83 | /** |
||
84 | * Encrypt a value using the RSA key |
||
85 | * |
||
86 | * @param $value |
||
87 | * @return false|string |
||
88 | * @throws RSAKeyFileMissing |
||
89 | */ |
||
90 | public function encrypt($value) |
||
95 | |||
96 | /** |
||
97 | * Decrypt a value using the RSA key |
||
98 | * |
||
99 | * @param $value |
||
100 | * @return false|string|null |
||
101 | * @throws RSAKeyFileMissing |
||
102 | */ |
||
103 | public function decrypt($value) |
||
112 | |||
113 | public function __call($name, $arguments) |
||
119 | } |
||
120 |