I am trying to encrypt some data in cakephp 3.5 with Security::encrypt.
I did a test:
$key = '111111111111111111111111111111111';
$enc = Security::encrypt('123', $key);
$dec = Security::decrypt($enc, $key);
Log::write(LOG_DEBUG, "Encrypt $key: $enc");
Log::write(LOG_DEBUG, "Decrypt $key: $dec");
In my log I get:
Encrypt 111111111111111111111111111111111: c4f3fd8f937afe66a6f211a4333c97be06700655c8f591f9b5bf3c85489a3c0a~ΊCdΔA€Νίύι_Yτ΅\i©EpcΛ*Kβ
Decrypt 111111111111111111111111111111111: 123
encrypted value is not an ANSI string? Decrypt is done correctlly but if I save this data to database and then decrypt it it fails to give me the correct original data. The problem is that not the correct encrypted key is saved to the database. My column (in mysql) in utf8_unicode_ci. What am I doing wrong?
Thanks