Page 1 of 1
SHA256 or higher...
Posted: Mon Jun 23, 2008 11:05 pm
by tecktalkcm0391
How do I use SHA256... I've been looking for 10 minutes now... and I can't find anything with its PHP use... and just making sure SHA256 is the highest PHP has so far, and at the moment most secure.
Re: SHA256 or higher...
Posted: Tue Jun 24, 2008 12:07 am
by jmut
http://php.net/hash - looking for hash () function
Re: SHA256 or higher...
Posted: Tue Jun 24, 2008 7:50 am
by tecktalkcm0391
Ok, well witch is better the hash function in PHP or the class that is on this forum....??? I read something, on that, but didn't really get it... its less secure to user SHA256(md5($text)); then sha256 by itselft.
Re: SHA256 or higher...
Posted: Tue Jun 24, 2008 9:11 am
by Kieran Huggins
feyd wrote a php4 implementation of sha256:
http://code.google.com/p/redwidow-dna/downloads/list
in php5 you can just use the hash() function as jmut suggested.
the php5 function would be faster, since it's compiled code.
Re: SHA256 or higher...
Posted: Tue Jun 24, 2008 3:19 pm
by jmut
tecktalkcm0391 wrote:Ok, well witch is better the hash function in PHP or the class that is on this forum....??? I read something, on that, but didn't really get it... its less secure to user SHA256(md5($text)); then sha256 by itselft.
I know nothing about algorithms... but seems kinda useless as you sha256 on constant length string.... which might be weakening stuff... You're pretty safe with just sha256
If you wanna use this for storing passwords you can check this really nice article by Mordred
viewtopic.php?t=62782
Re: SHA256 or higher...
Posted: Tue Jun 24, 2008 5:46 pm
by Eran
I'm pretty sure thats incorrect. Running nested hashing algorithms makes it harder to reverse engineer your hashed data from rainbow tables. The attacker would have to also guess your order of applying hashing algorithms, instead of attacking known algorithms directly.
Regarding weakening the strength of the hashing algorithm - each algorithm creates a unique string. Hashing it once more in another algorithm creates another unique string, it doesn't matter if it's fixed size or not, it's still unique non-reversible strings.
Re: SHA256 or higher...
Posted: Tue Jun 24, 2008 5:58 pm
by Kieran Huggins
double hashing increases the chances of a collision, since hashes are presumably a smaller set than the thing you're hashing the first time.
I also remember reading somewhere that double hashing is less secure, since there are exploits that knowing the second hash makes possible.
Re: SHA256 or higher...
Posted: Tue Jun 24, 2008 7:02 pm
by jayshields
Straight from Mordred's post, linked by jmut:
I. The school of doublehashing
The reasoning is that there are precomputed dictionaries for HASH(password), but not ones for HASH(HASH(password)), so here's an easy way to defeat password stealers. While this is true, the method still has the unpleasant property that Bob's and Cindy's doubly hashed passwords are still the same.
Apart from that, from a cryptological point of view, double hashing is considered insecure, although I suspect that in reality this would not impact anyone but an enemy of the NSA or something. I am not a cryptologist though, so I listen to what the experts are saying, which is not to do it. You may use this mantra in your daily meditations: Never never ever ever double double hash.
Personally, I dislike the term double hashing because it's the same term used for a probing algorithm when implementing hash sets, and in that sense, double hashing is the best way to go about things rather than a poor way in this case.
Re: SHA256 or higher...
Posted: Tue Jun 24, 2008 7:47 pm
by Eran
Can anyone bring concrete evidence as to why double hashing is unsecure?
Re: SHA256 or higher...
Posted: Wed Jun 25, 2008 8:21 am
by tecktalkcm0391
Wouldn't double hashing, when you don't just do md5(md5)) or similar be secure so something like:
Code: Select all
md5('qrstuvwxyz'.md5('abc'.$input.'dfg').'hijklmnop');
Because each hash will be hashing a even more unique hash that is not just the same original hashes length..
Re: SHA256 or higher...
Posted: Wed Jun 25, 2008 9:10 am
by Kieran Huggins
IIRC, double hashing's vulnerability was in the fact that the second hash has a MUCH smaller dictionary size, since the size of all known hashes is almost infinitely smaller than the size of all strings.
The hardcore math stuff in the article was beyond me, but the bottom line was that using a single hash with a salt was dramatically more secure.
I wish I'd bookmarked that article so I had smart people backing up my broken-telephone recount :-/
This entire argument seems to be getting a little ridiculous, IMO, since most users will pick rather insecure passwords anyway.
Besides, if someone can physically access or otherwise pwn your server, all of these measures become moot.
What a fun word: Moot. MOOOOOOT!
Re: SHA256 or higher...
Posted: Thu Jun 26, 2008 2:10 am
by jmut
Kieran Huggins wrote:....
Besides, if someone can physically access or otherwise pwn your server, all of these measures become moot.
Well why, ultimate idea is you need as much (same) amount of computation power to crack EACH pass (without salting, hashes of same passwords are same)...
Which I think makes big difference.
Re: SHA256 or higher...
Posted: Thu Jun 26, 2008 5:26 am
by jayshields
I think Kieran is getting at the fact that if someone can get access to your database and your web server you're screwed cos they can see the hashed strings and look at whatever hashing algorithm you used.
Re: SHA256 or higher...
Posted: Fri Jun 27, 2008 3:32 am
by jmut
jayshields wrote:I think Kieran is getting at the fact that if someone can get access to your database and your web server you're screwed cos they can see the hashed strings and look at whatever hashing algorithm you used.
I see, well it's clear that there is no ultimate security.... and that's why being secure is a process and not a state.
Anyhow

php rulz