PHP: Please check these 2 short scripts?

Does this code have all the things you need to check(security e.g. mysql_real_escape_string) before storing(and performing query) for a MySQL database in php?
---
function validateInput($value) {
if (get_magic_quotes_gpc()){
$value = stripslashes($value);
}
$value = mysql_real_escape_string($value);
}
_______________________________
Is this more secure then just one hasher(md5/sha1)?
It looks like a sha1 hash string but it is a combination of two.
---
function mergeStrings($str1, $str2) {
$str1 = str_split($str1,1);
$str2 = str_split($str2,1);
if (count($str1) >= count($str2)){
list($str1,$str2) = array($str2,$str1);
}
for($x=0; $x < count($str1); $x++){
$str2[$x] .= $str1[$x];
}
return implode('',$str2);
}
function dualHash($string1, $salt = "kpijCr3DkqRy") {
$dualHash1 = sha1($string.$salt);
$dualHash2 = md5($string.$salt);
$dualHash = substr($dualHash1,0,24);
$dualHash = mergeStrings($dualHash,substr($dualHash2,0,16));
return $dualHash;
}
 
Both secure but for different things, when you perform a query mysql_real_escape_string is what you need, and hash any passwords you save.
 
Back
Top