i'm creating users encrypted passwords on database using mcrypt method this:
$key = '1234567890123456'; $iv_size = mcrypt_get_iv_size(mcrypt_rijndael_256, mcrypt_mode_ecb); $iv = mcrypt_create_iv($iv_size); $encryp_pass = mcrypt_encrypt(mcrypt_rijndael_256, $key, $password2, mcrypt_mode_ecb, $iv); mysql_query("update usuarios set pass_usuario = '".$encryp_pass."' id_usuario = '".$id_user[0]."' "); ...so user created stored in database password encrypted.
now, when user logs system (or i'm trying do) encrypt password inputs on textfield compare value value on database. encrypt password same way did when creating user this:
$key = '1234567890123456'; $iv_size = mcrypt_get_iv_size(mcrypt_rijndael_256, mcrypt_mode_ecb); $iv = mcrypt_create_iv($iv_size); $encryp_pass = mcrypt_encrypt(mcrypt_rijndael_256, $key, $password, mcrypt_mode_ecb, $iv); $query_pass_existe = mysql_query("select pass_usuario usuarios nick_usuario = '".$nick."'"); $pass_user_fromdb = mysql_fetch_assoc($query_pass_existe); then compare both passwords: 1 extracted database , 1 encrypted login form:
if (utf8_encode($encryp_pass) == utf8_encode($pass_user_fromdb['pass_usuario'])) { echo 'both equals'; }else{ echo 'they're totally different'; } right now, i'm getting both different. print them see result:
echo utf8_decode($pass_user_fromdb['pass_usuario']); echo "<br>"; echo utf8_decode($encryp_pass); echo "<br>"; but alike, take look:
=???0?1y?y7h???[.?0????1m =???0?1y?y7h???\[.?0????1m they same because of \ can't continue login successfully. i've checked column , have set as: utf8_general_ci. i'm thinking on using aes encryption read on this article mysql better use mcrypt.
Comments
Post a Comment