Skip to content

Instantly share code, notes, and snippets.

@robertogallea
Created May 8, 2020 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertogallea/01a300cfeb73cbdb1d8d32f71d159c2c to your computer and use it in GitHub Desktop.
Save robertogallea/01a300cfeb73cbdb1d8d32f71d159c2c to your computer and use it in GitHub Desktop.
$encrypted2 = $encrypter->encrypt('Hello hacker');
$decodedEncrypted2 = json_decode(base64_decode($encrypted2), true);
dump('DECODED ENCRYPTED 2: ');
var_dump($decodedEncrypted2);
```
Now, in turn, try to tamper one or more of the three values and attempt to decrypt the result.
```
// swapping the ciphered data and try to decipher
try {
$tampered = $decodedEncrypted;
$tampered['value'] = $decodedEncrypted2['value'];
$encrypter->decrypt(base64_encode(json_encode($tampered)));
} catch (\Illuminate\Contracts\Encryption\DecryptException $exception) {
dump($exception->getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment