CodeIgniter Forums

Full Version: Encryption Service has strange characters
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone

Using the Encryption library, the result of the '$encrypter->encrypt('This is a plain-text message!')', returns strange characters like this: 



[C�<��ɪ�˓T��H- 9t�g噾��B7��/���d� ��Ɲ�'�y`�@��@��L�$��[�M����D�?Ʃ�h�zt�%�M\ �hС����B!�)�



 is that correct?

I'm using version 4.0.2 stable

Thanks
That looks like binary data to me. Haven't looked in the code, but I don't see any reason it would not be valid.

You can save it as is in binary form in the database or base64 encode it. But then you need to base64 decode it before decryptning it.
(03-02-2020, 11:27 AM)jreklund Wrote: [ -> ]That looks like binary data to me. Haven't looked in the code, but I don't see any reason it would not be valid.

You can save it as is in binary form in the database or base64 encode it. But then you need to base64 decode it before decryptning it.


Cool, using base64_encode / decode I can pass the coded value to the url, thanks.
Hi, I just recommended the wrong function yesterday... You should use bin2hex and hex2bin.
https://www.php.net/manual/en/function.bin2hex.php
https://www.php.net/manual/en/function.hex2bin.php