Homemade Hash Recipe
Security by obscurity is OK sometimes.
Securing login data by using SHA* or MD5 is good.
If done carefully, brute force guessing can be essentially neutralized.
For example, code like
Code:
md5(sha*(sha*(md5(md5(sha*("aa"))))))
seems excessive.
A simpler way is simply to use an arbitrary, but consistent, rule to modify the hash in a way known ONLY to you and no other. Without this secret info, no amount of ordinary brute force will crack the hash in any practical time period. Mission accomplished.
Code:
$hash = md5("John");
When I execute this, it returns
$hash = "6*40*aa*fd47d4a5**2de2*cbf5*a*6f"
Instead of leaving it that way, you could apply a 'private rule', such as swapping the **th character with the final character of the hash string before storing it.
In the above example
$hash = "6*40*aa*fd47d4a5**2de2*cbf5*a*6f"
would become:
"6*40*aa*fd47f4a5**2de2*cbf5*a*6d"
Brute force will NOT find 'John' from this hash.
The **th character 'f' was swapped with the final character 'd' to break the brute force method.
Before comparing, we repeat the swap, to restore the hash to normal.
ANY SIMPLE RULE WILL DO
It can be ANY simple convenient rule that transparently alters the hash from its original sequence but can be easily undone to restore the original hash.
To use the hash, simply reverse the process before comparing it. If someone stole your password list encrypted in this manner, would it simply occur to them to swap the **th and the final characters prior to attempting to crack it by brute force? Not likely.
The change is essentially invisible and without that special prior knowledge of the required minor change, nobody is likely to crack the hash. It's like the secret ingredient your mum uses in a recipe. Even if Russian spies steal her recipe, they still don't know about the secret ingredient not mentioned and will not get exactly the same result without it.
This is a case where security by obscurity is OK, very simple and quite effective.
The programming of this method is not difficult and its power and effectiveness lies in making sure that ONLY YOU know the secret of the hash.
I do the same with PGP encryption too. I have to change * characters before PGP can be decrypted. Knowing the pass phrase is not enough in itself if you don't know which * characters to change first prior to decryption.
Knowledge is power, and secret knowledge is even greater power.
Last edited by JayT; 04-25-2008 at 03:23 PM.
Oh to be free, so blissfully free, of the ravages of intelligence, there is no greater joy! - The Cweationist's Cweed
All that is necessary for evil to triumph is a good PR firm.
Very funny, Scotty. Now beam down my clothes!