• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Encryption Service - broken characters

#1
Hello guys, I need help with the problem what i got.
When using the Encryption service and encrypt some data i always got improperly encoded characters.

For example


Code:
<a href="" charset="UTF-8" data-text="<?= $encrypter->encrypt(10) ?>">test</a>
produce
Code:
<a href="" charset="UTF-8" data-text="�c�NK���a�ǃ���:�0��8�m���v��C7��M�Y���v]s*���BL��t��M��Y����<c����I1�1�z�">test</a>

I´m using CI4 rc3 with config set to utf-8,PHP 7.2.26 running on localhost, developing in php storm which encoding is set to utf-8.
I tried output to log, print on screen, insert to db and i always a got broken chars.
Thank you very much for help.
Reply

#2
I think you need to base64 encode and decode it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(01-30-2020, 01:33 AM)TonyC Wrote: Hello guys, I need help with the problem what i got.
When using the Encryption service and encrypt some data i always got improperly encoded characters.

For example


Code:
<a href="" charset="UTF-8" data-text="<?= $encrypter->encrypt(10) ?>">test</a>
produce
Code:
<a href="" charset="UTF-8" data-text="�c�NK���a�ǃ���:�0��8�m���v��C7��M�Y���v]s*���BL��t��M��Y����<c����I1�1�z�">test</a>

I´m using CI4 rc3 with config set to utf-8,PHP 7.2.26 running on localhost, developing in php storm which encoding is set to utf-8.
I tried output to log, print on screen, insert to db and i always a got broken chars.
Thank you very much for help.

You need to convert the binary string that encryption outputs into hex. base64_encode and its compliment base64_decode is one solution. The other solution is to use the complementary functions bin2hex and hex2bin

Read the docs for more
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.