I have the following code in php:
$salt = bin2hex(openssl_random_pseudo_bytes(22));
$hash = crypt($this->input->post("defpswd"), "$2y$12$".$salt);
If i try to save $hash value to a MSSQL database table with a varbinary datatype field, i get the error message:
[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query.
$hash variable contains:
'$2y$12$35695d29f921c713eba4fu1VY0q6VF6HryPH9HjiLvHOoupXWvPn.'
If i cast $hash by using binary as in is it possible to convert a string to varbinary in PHP without using the SQL function i get the same error. I am using CodeIgniter and MSSQL database with an odbc connection. What is it that i am not getting right? Thank you.