| Conditions | 1 |
| Paths | 1 |
| Total Lines | 22 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 26 | public function testFailedDecryption() |
||
| 27 | { |
||
| 28 | require_once __DIR__ . '/../vendor/autoload.php'; |
||
| 29 | |||
| 30 | $passphrase = 'test-passphrase'; |
||
| 31 | |||
| 32 | $cryptoGuard = new \Coreproc\CryptoGuard\CryptoGuard($passphrase); |
||
| 33 | |||
| 34 | $stringToEncrypt = 'test string to encrypt'; |
||
| 35 | |||
| 36 | $encryptedText = $cryptoGuard->encrypt($stringToEncrypt); |
||
| 37 | |||
| 38 | // decrypt the string |
||
| 39 | $decryptedText = json_decode(base64_decode($encryptedText), true); |
||
| 40 | |||
| 41 | $decryptedText['iv'] = 'changed-iv-for-test'; |
||
| 42 | |||
| 43 | // encrypt again |
||
| 44 | $encryptedText = base64_encode(json_encode($decryptedText)); |
||
| 45 | |||
| 46 | $decryptedText = $cryptoGuard->decrypt($encryptedText); |
||
| 47 | } |
||
| 48 | |||
| 49 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.