phpsec.org— This article will explain what a hash is, why you want to use them instead of storing real passwords in your applications, and give you some examples of how to implement password hashing in PHP and MySQL.
May 28, 2006View in Crawl 4
don't bet on them being unable to obtain hashs.and you can buy rainbow crack tables with all combinations up to like 7 characters precomputed for you, which makes finding out what that password is VERY easy.it's a much better approch to use the databases authentication methods.also just to nit pick, but hashing is NOT encryption. things like rainbow tables do not work against something encrypted
"MD5 has a reputation of *frequent collisions. I.E. multiple words mapping to the same hash."Uh, no. The only collisions known for MD5 are those deliberately constructed by cryptanalysts using the Wang attack or variants thereof. No collisions have ever arisen "by accident".
Why make one function do double duty? Something like this would be cleaner (not PHP, I don't speak that)def hash_password(salt, password): h = salt + password for i in range(num_iters): h = sha1(h) return hdef new_password(password): salt = new_salt(salt_len) return salt + hash_password(salt, password)def check_password(dbentry, password): return dbentry[salt_len:] == hash_password(dbentry[:salt_len], password)
The option we're going for is to store the hash of a password generated by an algorithm guaranteed to have many, many collisions. As long as the collisions per hash bucket are significant enough to indicate a correct password, but low enough to be very small compared with the overall password space, then you might be ok. For example, if you have an algorithm that will have 100,000 collisions per bucket, but over a password space of 1,000,000,000,000 possible combinations, then only 0.1% of the possible passwords will hash to a given hash value, giving you 99.9% certainty a correct password was entered. If you can live with 99.9% instead of 100% when checking passwords, they you protect your hashed passwords from brute force or precomputed validation, even if your hashing algorithm is known (not secret). A successful match by a hacker would still leave them with 100,000 possible passwords to have to try against some other validation site (assuming your passwords are used in more than one system).
Closed AccountMay 29, 2006
don't bet on them being unable to obtain hashs.and you can buy rainbow crack tables with all combinations up to like 7 characters precomputed for you, which makes finding out what that password is VERY easy.it's a much better approch to use the databases authentication methods.also just to nit pick, but hashing is NOT encryption. things like rainbow tables do not work against something encrypted
cavicsterMay 29, 2006
Thanks for the link, I didn't know about that. PHP 5.1.2 is bundled with a new hash extension which supports many algorithms.<a class="user" href="http://us3.php.net/manual/en/function.hash-algos.php">http://us3.php.net/manual/en/function.hash-algos.php</a>
nitenMay 29, 2006
Perfect timing; I just started writing my first real LAMP app, and this is exactly what I was looking for. Thanks, vagabond0101!
ciphergothMay 29, 2006
"MD5 has a reputation of *frequent collisions. I.E. multiple words mapping to the same hash."Uh, no. The only collisions known for MD5 are those deliberately constructed by cryptanalysts using the Wang attack or variants thereof. No collisions have ever arisen "by accident".
donwilsonMay 30, 2006
Welcome to Day 1 of PHP/MySQL development.
ciphergothMay 30, 2006
Why make one function do double duty? Something like this would be cleaner (not PHP, I don't speak that)def hash_password(salt, password): h = salt + password for i in range(num_iters): h = sha1(h) return hdef new_password(password): salt = new_salt(salt_len) return salt + hash_password(salt, password)def check_password(dbentry, password): return dbentry[salt_len:] == hash_password(dbentry[:salt_len], password)
no_tellinJun 1, 2006
The option we're going for is to store the hash of a password generated by an algorithm guaranteed to have many, many collisions. As long as the collisions per hash bucket are significant enough to indicate a correct password, but low enough to be very small compared with the overall password space, then you might be ok. For example, if you have an algorithm that will have 100,000 collisions per bucket, but over a password space of 1,000,000,000,000 possible combinations, then only 0.1% of the possible passwords will hash to a given hash value, giving you 99.9% certainty a correct password was entered. If you can live with 99.9% instead of 100% when checking passwords, they you protect your hashed passwords from brute force or precomputed validation, even if your hashing algorithm is known (not secret). A successful match by a hacker would still leave them with 100,000 possible passwords to have to try against some other validation site (assuming your passwords are used in more than one system).
mydaveJul 31, 2008
to understand you must also read about hash tables.<a class="user" href="http://chasr.org">http://chasr.org</a><a class="user" href="http://sooslic.com/?id=118">http://sooslic.com/?id=118</a>
Closed AccountSep 8, 2008
The best mortgage rates, refinance, home loan, real estate, realty <a class="user" href="http://tophomemortgageloan.com">http://tophomemortgageloan.com</a>