Carlton Posted July 21, 2010 Share Posted July 21, 2010 Apparently everytime I run this query it always claims it's the wrong password when I encrypted it in the correct way. $escape = mysql_real_escape_string($_POST['password']); $escape2 = mysql_real_escape_string($_POST['username']); $query = mysql_query("SELECT * FROM Accounts WHERE Name ='" . $escape2 . "' AND Password = md5(sha1('" . hash( 'whirlpool', $escape ) . "'))") or die('Cannot Execute:'. mysql_error()); If you're curious how I encrypted it view here: (This is from another language) mysql_real_escape_string(inputtext, Escape[0]); WP_Hash(Escape[1], 150, Escape[0]); format(string, STR_SIZE, "SELECT * FROM Accounts WHERE Name = '%s' AND Password = md5(sha1('%s'))", GetUserName(playerid), Escape[1]); if(!mysql_query(string)) SendScriptError(playerid, MySQL_ERROR_CHECKPASSWORD_FAILURE); Quote Link to comment https://forums.phpfreaks.com/topic/208375-invalid-password-strangly/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 21, 2010 Share Posted July 21, 2010 A) Is your password field in your table large enough to hold an md5() value (32 hex characters), and B) You are the only one here who can troubleshoot what your code is doing. How about checking if the value your query produces (form a SELECT query using the same logic you are putting into the WHERE clause) and what is actually stored in your database are the same. Quote Link to comment https://forums.phpfreaks.com/topic/208375-invalid-password-strangly/#findComment-1088922 Share on other sites More sharing options...
Carlton Posted July 21, 2010 Author Share Posted July 21, 2010 A) Is your password field in your table large enough to hold an md5() value (32 hex characters), and B) You are the only one here who can troubleshoot what your code is doing. How about checking if the value your query produces (form a SELECT query using the same logic you are putting into the WHERE clause) and what is actually stored in your database are the same. Hi, printing out the whirlpool shows about 20+ characters, once doing that in another language and implementing it, the database only stops at about 10 characters, how can I increase the maximum character size in the Password field? Quote Link to comment https://forums.phpfreaks.com/topic/208375-invalid-password-strangly/#findComment-1088925 Share on other sites More sharing options...
PFMaBiSmAd Posted July 21, 2010 Share Posted July 21, 2010 So, did you even make an effort to find and change the size of your password field? Quote Link to comment https://forums.phpfreaks.com/topic/208375-invalid-password-strangly/#findComment-1089183 Share on other sites More sharing options...
Zane Posted July 21, 2010 Share Posted July 21, 2010 Are you using MySQL's MD5/SHA hash or PHP's If you meant to use PHP's then you have a parse error -try this cape2 . "' AND Password = '" . md5(sha1(hash( 'whirlpool', $escape ). "') or die Quote Link to comment https://forums.phpfreaks.com/topic/208375-invalid-password-strangly/#findComment-1089185 Share on other sites More sharing options...
Carlton Posted July 21, 2010 Author Share Posted July 21, 2010 So, did you even make an effort to find and change the size of your password field? Obviously, otherwise I wouldn't even be replying, would I? Are you using MySQL's MD5/SHA hash or PHP's If you meant to use PHP's then you have a parse error -try this cape2 . "' AND Password = '" . md5(sha1(hash( 'whirlpool', $escape ). "') or die Both. I'll check out the code. Quote Link to comment https://forums.phpfreaks.com/topic/208375-invalid-password-strangly/#findComment-1089186 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.