I have this question, excuse me if this does not fit, tell me in the comments and I will drop it. The point is: I generate salt using this code:
$salt = mcrypt_create_iv(32);
And the password this way:
$password = hash('sha256', $_POST['password'] . $salt);
and save $ salt and $ password in the MYSQL database until there is no problem if I connect this path:
$pdo = new PDO(
'mysql:host=hostname;dbname=defaultDbName',
'username',
'password'
);
But if I connect this other way:
$pdo = new PDO(
'mysql:host=hostname;dbname=defaultDbName;charset=utf8',
'username',
'password'
);
salt is not stored in the database or is stored with the wrong value and length; if I do not do this: $ salt = utf8_encode (mcrypt_create_iv (32);); But I think this is wrong, I mean, why should I encode this, what is the problem with mcrypt_create_iv (32) and utf-8?
source
share