Join the forums now, and start posting to receive access to our Scripts Vault!
mysql_real_escape_string(sha256($password)));
The thing is... isn't the result of sha256 consisting solely of alfanumeric characters which would not broke the query anyhow? The escaping function would have no effect then...which is what I believe
Code: [Select]mysql_real_escape_string(sha256($password)));Ok now personally to me it should sha256 the $password variable, then it'd attempt to escape the characters that shouldn't be there. Is this true? Or does it strip the special characters then do an sha256? If it does the former, i'll just put that up higher in the registration/login script.
Quote from: 133794m3r on February 10, 2010, 01:49:54 AMCode: [Select]mysql_real_escape_string(sha256($password)));Ok now personally to me it should sha256 the $password variable, then it'd attempt to escape the characters that shouldn't be there. Is this true? Or does it strip the special characters then do an sha256? If it does the former, i'll just put that up higher in the registration/login script.You don't have to worry about SQL injection on this line.sha256 can safely accept any character as input. Barring any serious as-yet-undiscovered bugs in PHP's implementation of sha256, it can safely handle any input given to it, so there's no need to worry about escaping anything there.The actual output of the sha256 algorithm is just a string of bits, which is then encoded into something more readable for output; your implementation appears to be encoding it as hexadecimal, but base64 encoding is also common for that sort of thing. In either case, the character set into which it is encoded is 100% SQL-safe, so there is no need to post-process that encoded representation to prevent SQL injection.