1 | <?php |
||
23 | class Encrypter implements EncrypterInterface, InjectableInterface |
||
24 | { |
||
25 | /** |
||
26 | * Injector is dedicated to outer class since Encrypter is pretty simple. |
||
27 | */ |
||
28 | const INJECTOR = EncrypterManager::class; |
||
29 | |||
30 | /** |
||
31 | * @var Key |
||
32 | */ |
||
33 | private $key = null; |
||
34 | |||
35 | /** |
||
36 | * Encrypter constructor. |
||
37 | * |
||
38 | * @param string $key Loads a Key from its encoded form (ANSI). |
||
39 | */ |
||
40 | public function __construct(string $key) |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | public function withKey(string $key): EncrypterInterface |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | public function getKey(): string |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | * |
||
67 | * Data encoded using json_encode method, only supported formats are allowed! |
||
68 | */ |
||
69 | public function encrypt($data): string |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | * |
||
83 | * json_decode with assoc flag set to true |
||
84 | */ |
||
85 | public function decrypt(string $payload) |
||
98 | } |
||
99 |