1 | <?php |
||
16 | class Security |
||
17 | { |
||
18 | /** @var string */ |
||
19 | const VERSION = 'HMAC_SHA256_V1'; |
||
20 | |||
21 | /** |
||
22 | * Encode merchant parameters |
||
23 | * |
||
24 | * @param array $data The parameters to encode |
||
25 | * |
||
26 | * @return string Encoded data |
||
27 | */ |
||
28 | 1 | public function encodeMerchantParameters($data) |
|
32 | |||
33 | /** |
||
34 | * Decode merchant parameters |
||
35 | * |
||
36 | * @param string $data The encoded string of parameters |
||
37 | * |
||
38 | * @return array Decoded data |
||
39 | */ |
||
40 | 9 | public function decodeMerchantParameters($data) |
|
44 | |||
45 | /** |
||
46 | * Encrypt message with given key and default IV |
||
47 | * |
||
48 | * @param string $message The message to encrypt |
||
49 | * @param string $key The key used to encrypt the message |
||
50 | * |
||
51 | * @return string Encrypted message |
||
52 | * |
||
53 | * @throws RuntimeException |
||
54 | */ |
||
55 | 11 | protected function encryptMessage($message, $key) |
|
67 | |||
68 | /** |
||
69 | * Check if the system has a valid encryption method available |
||
70 | * |
||
71 | * @todo add or switch to extension_loaded()? |
||
72 | * |
||
73 | * @return bool |
||
74 | */ |
||
75 | 9 | public function hasValidEncryptionMethod() |
|
79 | |||
80 | /** |
||
81 | * Create signature hash used to verify messages |
||
82 | * |
||
83 | * @todo Add if-check on algorithm to match against signature version as new param? |
||
84 | * |
||
85 | * @param string $message The message to encrypt |
||
86 | * @param string $salt Unique salt used to generate the ciphertext |
||
87 | * @param string $key The key used to encrypt the message |
||
88 | * |
||
89 | * @return string Generated signature |
||
90 | */ |
||
91 | 9 | public function createSignature($message, $salt, $key) |
|
96 | |||
97 | 8 | public function createReturnSignature($message, $salt, $key) |
|
101 | } |
||
102 |