I need to be able to encrypt data, it is just simple information, nothing to worry about in terms of security, I need to pass this encrypted information by method GET
, for example:
example.com/?dato=aHDwbejferbdscb23zs
So for this I am using openssl_encrypt
and openssl_decrypt
having the following:
$url = 'https://stackoverflow.com';
$key_encrypt = '1234567812345678';
$iv = '1234567812345678';
$encrypt = openssl_encrypt($url, "AES-128-CBC", $key_encrypt, FALSE, $iv);
$decrypt = openssl_decrypt($encrypt, "AES-128-CBC", $key_encrypt, FALSE, $iv);
The problem is that this encryption can create special characters for me, for example:
ncG1vNJzZmihkW19coCPcGWuq16Wv6S0yK%2BcZ6einHx2e8itnKarX2d9dquRaWlqaGdng3B%2Bj25lopleor11==
And, by passing this information by method GET
, I will not be able to decipher said information by said characters.
So the question is the following, there is a possibility that the cipher is not that long, this is optional. What I do require is that the encryption is only of a-Z
and numbers 0-9
without adding special characters that harm the verification by methodGET
I recommend you to use the JWT library that converts an array to a string(JSON) which can be passed by URL
Here you have the documentation and the JWT library
Here is an example