lundi 28 janvier 2019

Laravel 5.5 - Crypt::decrypt work in browser but given error "The MAC is invalid." when called using CURL

I have a problem at Laravel. I have encrypted data and a function to decrypt it. When the URL Route is accessed through the browser, the page displays the correct contents. But when the URL is called by CURL, there is a "MAC is invalid" error return.

I have already run:

composer dump-autoload

composer clear-cache

php artisan cache:clear

But didn't help. Can anyone provide a solution?

Code:

use Crypt;

...

public function getProfile($request)
{
    $profile = DB::table('user_profiles')->where('user_id',$request->user_id)->value('hash_data');
    /* decrypt */
    $profile_plain = Crypt::decrypt($profile);      
    $data = json_decode($profile_plain);        
    return response()->json([$data->personal]);
}

Using browser:

enter image description here

Using CURL:. enter image description here

Thank you for your help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire