1 | <?php |
||
20 | class Encrypter implements EncrypterInterface, InjectableInterface |
||
21 | { |
||
22 | /** |
||
23 | * Injection is dedicated to outer class since Encrypter is pretty simple. |
||
24 | */ |
||
25 | const INJECTOR = EncrypterManager::class; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $key = ''; |
||
31 | |||
32 | /** |
||
33 | * Encrypter constructor. |
||
34 | * |
||
35 | * @param string $key |
||
36 | */ |
||
37 | public function __construct($key) |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function withKey($key) |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function getKey() |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | * |
||
64 | * @todo double check |
||
65 | * @param bool $passWeak Do not throw an exception if result is "weak". Not recommended. |
||
66 | */ |
||
67 | public function random($length, $passWeak = false) |
||
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | * |
||
90 | * Data encoded using json_encode method, only supported formats are allowed! |
||
91 | */ |
||
92 | public function encrypt($data) |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | * |
||
108 | * json_decode with assoc flag set to true |
||
109 | */ |
||
110 | public function decrypt($payload) |
||
124 | } |
||
125 |