I have a variable which has to be encrypted and after that saved to the database via mysqli prepared statement. I use AES-256-CTR.
$tabvar = openssl_encrypt($final, $encryptionMethod, $secret, OPENSSL_RAW_DATA, $iv);
After the encryption the result looks like this: 5œœ¼Ç=áüû;€é?
This is my php insert code:
$ins = mysqli_prepare($db, "INSERT INTO tab (tid, tabvar) VALUES (?,?)");
mysqli_stmt_bind_param($ins, "ss",$tid,$tabvar); mysqli_stmt_execute($ins);
Because the $tabvar consist of some very strange characters once encrypted, it doesn't get inserted in the database. If I change $tabvar to "i" the row get's inserted, but the entry under tabvar column is 0?
Does anyone have an idea how to solve this?