So far as the dictionary attacks are concerned, I thought up the following function:
<?php
function twistSTR($array){
$twisted="";
$array_strlen=array();
foreach ($array as $element){
$array_strlen[]=strlen($element);
}
for ($i=0; $i<max($array_strlen); $i++){
foreach ($array as $element){
if ($i<strlen($element)){
$twisted=$twisted.$element{$i};
}
}
}
return $twisted;
}
?>
The twistSTR function basically takes an array input of strings and alternates each character of each string among all the other strings. For example:
<?php
echo twistSTR(array("this","and","that"));?>
It can be applied in the following manner:
<?php
if ($un===$_POST["username"] && $pwd===sha1(twistSTR(array($salt,$_POST["password"])))){
?>
It's not amazingly difficult to reverse engineer the actual output, but then again, that's not the point. The point is that when a password is entered into one of those databases, they are going to enter for example "thisandthat", not "tathnhidast".