(string $data, string $key)
| 25 | } |
| 26 | |
| 27 | function decryptForTest(string $data, string $key): string |
| 28 | { |
| 29 | $cipher = 'AES-256-CBC'; |
| 30 | $raw = base64_decode($data); |
| 31 | $ivlen = openssl_cipher_iv_length($cipher); |
| 32 | $iv = substr($raw, 0, $ivlen); |
| 33 | $ct = substr($raw, $ivlen); |
| 34 | return openssl_decrypt($ct, $cipher, $key, OPENSSL_RAW_DATA, $iv) ?: ''; |
| 35 | } |
| 36 | |
| 37 | function writeEncryptedJson(string $path, array $payload, string $key): void |
| 38 | { |