php - Why open_ssl function returns strange charartes using DES-EDE3-CBC?

I have a problem with decrypting a hex string using the openssl_decrypt function. It returns strange characters.
The function is this:
$ params_decrypt = openssl_decrypt ($ params_hex, "DES-EDE3-CBC", "e238a0d8c9d82a8083b878e2fafc76216d3d0776a63bdf39", OPENSSL_ZERO_PADDING, "cca6662d330");
echo "<br> <br> string_decrypt4345643xxxxYaEs <br> <br>". $ params_decrypt;
Returns this on the web page configured for UTF-8
пїЅпїЅQпїЅпїЅпїЅrпїЅ84fЪ±hпїЅx^XпїЅC#пїЅпїЅпїЅ-пїЅ~Д«xпїЅпїЅG%E-]}ИҐ[пїЅЪ±/пїЅпїЅP7пїЅпїЅUпїЅsпїЅпїЅпїЅ.yпїЅ(wпїЅпїЅпїЅпїЅ5SmKпїЅпїЅ!QпїЅпїЅ6пїЅпїЅ1пїЅпїЅ:пїЅ4пїЅпїЅпїЅпїЅ]пїЅпїЅпїЅпїЅпїЅ_5sпїЅp&MЦґпїЅRпїЅrlIмљЋпїЅпїЅпїЅA/NпїЅ2пїЅпїЅпїЅпїЅJ^{пїЅпїЅпїЅпїЅvsb пїЅпїЅ\пїЅ.пїЅDпїЅпїЅ!пїЅ
пїЅ@пїЅDsпїЅ }пїЅпїЅпїЅ^пїЅZпїЅc$пїЅЕ‰пїЅпїЅпїЅЦ¬пїЅeРЏDпїЅ'пїЅпїЅ.пїЅh$пїЅпїЅoM)пїЅпїЅz@vпїЅпїЅ-пїЅ,lпїЅпїЅVNrPпїЅУњпїЅпїЅпїЅyпїЅпїЅ=пїЅ,{пїЅn:JЕ«$пїЅпїЅpЦпїЅeпїЅ!tпїЅrпїЅпїЅ6'?oVпїЅЖ®)пїЅ"IпїЅ(пїЅ[пїЅпїЅпїЅ}D?пїЅпїЅD?пїЅпїЅ9&rпїЅ]пїЅAпїЅпїЅ5пїЅпїЅDjпїЅLпїЅdпїЅпїЅКѕпїЅ*пїЅпїЅпїЅпїЅпїЅпїЅRпїЅпїЅпїЅXпїЅпїЅпїЅпїЅпїЅпїЅ6пїЅпїЅпїЅпїЅпїЅbiпїЅgпїЅОёoпїЅпїЅп‰іпїЅ}YпїЅпїЅW}\пїЅ"пїЅпїЅ
IseпїЅпїЅkHж·пїЅпїЅпїЅSпїЅf[пїЅm9sпїЅпїЅ:пїЅЕ«пїЅпїЅG5ХњпїЅNgпїЅ0UпїЅпїЅпїЅпїЅ$yпїЅrпїЅ=AпїЅGпїЅsпїЅ(5пїЅvпїЅiQпїЅ?пїЅпїЅпїЅlWTпїЅgeпїЅkпїЅпїЅ7пїЅпїЅXпїЅпїЅпїЅ :пїЅP_XпїЅiпїЅ&7пїЅ|vпїЅпїЅпїЅпїЅпїЅ@пїЅЭ¶UпїЅпїЅпїЅ%пїЅoпїЅYW13пїЅZпїЅпїЅnпїЅпїЅФѕK'AпїЅ~пїЅиќ·пїЅ$пїЅ`пїЅпїЅпїЅпїЅпїЅYпїЅпїЅпїЅпїЅkпїЅsпїЅ$пїЅ?!пїЅ|пїЅ4~пїЅпїЅпїЅ~пїЅпїЅпїЅjFпїЅпїЅ*пїЅпїЅпїЅfIпїЅTkvd[пїЅпїЅпїЅпїЅУЄпїЅ>пїЅпїЅпїЅ?j4( Ь?пїЅпїЅ%tпїЅпїЅпїЅТњпїЅ0쥟��DпїЅ
Regards.
Answer
Solution:
Solved.
I forgot to convert hexadecimal value to string.
$data = urlencode($_GET["PARAM"]);
$method = "DES-EDE3-CBC";
$key = "e238a0d8c9d82a8083b878e2fafc76216d3d0776a63bdf39";
$iv = "cca6662d3304033c";
$options = 0;
// transform the key from hex to string
$key = pack("H*", $key);
// transform the iv from hex to string
$iv = pack("H*", $iv);
// decrypt
$dec = openssl_decrypt(urldecode($data), $method, $key, $options, $iv);
Regards.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: unable to determine current zabbix database version: the table "dbversion" was not found.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.