mercredi 29 mars 2017

decrypt random error with Laravel's built-in encryption facilities

I send invitation by mail to users with a encrypted email to know which user respond to invitation. Something like:

Hello, click on this link to start learning: http://ift.tt/2oyyxpH

The encrypted email is the long string above. I encode mail like this in a Mailable class:

$url = 'http://ift.tt/2nM3qdd' . encrypt($this->to[0]['address']);

Then this $url is added in a mail template like this:

<a href=">click me<a>

Then, when user clicks the link, it routes to a controller and the controller decrypts the payload:

decrypt($request->input('e'));

Then, it works for about 99% of people clicking link. But for about one percent, it does not work, I have an error decrypting. And I don't know why. This is the same Laravel application which encrypts and decrypts. Is there an reason for such a weird behavior?

Side note: I know decrypt always work and has not a random behavior. I tested it on 10000 entries, it's OK. There must be something else with the mail process I don't understand.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire