Reputation: 269
I'm using Hash::make to hash the customer id in my laravel api controller. But when I return the Hashed customer id I get wrong characters. Here is my code:
$key=Hash::make($input['key']);
$createnewkey=DB::table('customers')->where('custid', $input['custid'])
->update(array("key"=>$key));
return ["STATUS"=>1, "KEY"->$key];
I got for example : Av$@wqe@!3aferty10/2YyAU .... and that's saved in the database.
But the request response is : Av$@wqe@!3aferty10/\2YyAU the \ or / is always replaced with /\ that will corrupt my hash code compare
Upvotes: 0
Views: 91
Reputation: 2553
Laravel Hash
use the password_hash
function of the PHP
. This function will generate the base64 encoded string. Which has the /
in its character list. So if you will pass that in the URL your URL will get corrupted.
Instead, you can use hashids
to encrypt the keys which are passed in URls.
This is the hashids
port for laravel : https://github.com/vinkla/laravel-hashids
Upvotes: 1