1 | <?php |
||
13 | class EloquentEncryption implements Encrypter |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var RsaKeyHandler |
||
18 | */ |
||
19 | private $handler; |
||
20 | |||
21 | /** |
||
22 | * ApplicationKey constructor. |
||
23 | */ |
||
24 | public function __construct() |
||
34 | |||
35 | /** |
||
36 | * Have any RSA keys been generated |
||
37 | * |
||
38 | * @return bool |
||
39 | */ |
||
40 | public function exists() |
||
44 | |||
45 | /** |
||
46 | * Generate a set of RSA Keys which will be used to encrypt the database fields |
||
47 | */ |
||
48 | public function makeEncryptionKeys() |
||
53 | |||
54 | /** |
||
55 | * Create a digital set of RSA keys, defaulting to 4096-bit |
||
56 | * |
||
57 | * @param string $email |
||
58 | * @return array |
||
59 | */ |
||
60 | public function createKey($email = '') |
||
68 | |||
69 | /** |
||
70 | * Helper function to ensure RSA options match for encrypting/decrypting |
||
71 | * |
||
72 | * @param $key |
||
73 | * @return RSA |
||
74 | */ |
||
75 | private function getRsa($key) |
||
83 | |||
84 | /** |
||
85 | * Encrypt a value using the RSA key |
||
86 | * |
||
87 | * @param $value |
||
88 | * @param bool $serialize |
||
89 | * @return false|string |
||
90 | * @throws RSAKeyFileMissing |
||
91 | */ |
||
92 | public function encrypt($value, $serialize = true) |
||
97 | |||
98 | /** |
||
99 | * Encrypt a string without serialization. |
||
100 | * |
||
101 | * @param string $value |
||
102 | * @return string |
||
103 | * |
||
104 | * @throws RSAKeyFileMissing |
||
105 | */ |
||
106 | public function encryptString($value) |
||
110 | |||
111 | /** |
||
112 | * Decrypt a value using the RSA key |
||
113 | * |
||
114 | * @param $value |
||
115 | * @param bool $unserialize |
||
116 | * @return false|string|null |
||
117 | * @throws RSAKeyFileMissing |
||
118 | */ |
||
119 | public function decrypt($value, $unserialize = true) |
||
130 | |||
131 | /** |
||
132 | * Decrypt the given string without unserialization. |
||
133 | * |
||
134 | * @param string $payload |
||
135 | * @return string |
||
136 | * |
||
137 | * @throws RSAKeyFileMissing |
||
138 | */ |
||
139 | public function decryptString($payload) |
||
143 | |||
144 | public function __call($name, $arguments) |
||
150 | } |
||
151 |