![]() |
Encryption Methods
I wanted to see the speed of the methods, the final results of each are from encrypting 1 sentance 300,000 times in a loop.
Round 1 MD5 generated in 0.350 seconds. Base64 generated in 0.007 seconds. CRC32 generated in 0.006 seconds. SHA1 generated in 0.012 seconds. Round 2 MD5 generated in 0.360 seconds. Base64 generated in 0.008 seconds. CRC32 generated in 0.006 seconds. SHA1 generated in 0.012 seconds. Round 3 MD5 generated in 0.362 seconds. Base64 generated in 0.007 seconds. CRC32 generated in 0.007 seconds. SHA1 generated in 0.012 seconds. Feel free to discuss :) |
I'm not too sure if base64 encoding has a place in a comparison like this -- being the only method here which is two-way. Interestingly, my own tests on my local machine suggest that SHA1 is slowest, closely followed by MD5, then in about one third of the time comes in base64_encode again closely followed by the winner (for me) CRC32. Clearly, a different pattern than is shown above!
I'd like to investigate further with more thorough benchmarking, just out of curiosity more than usefulness. :) |
Why is MD5 so slow in comparison to SHA1? Being a shorter hash I'd have expected it to have been somewhat faster. Armed with the fact that both SHA1 and MD5 are irreversible, does it not seem logical to suggest that MD5 is technically worse than SHA1?
|
I just did a quick test:
First Test (for loop) I used the string 'talkphp' and looped each method 300000 times in a for loop.rounded to 3dp SHA-1 : 0.349 //average MD5: 0.307 //average Second Test (while loop) I used the same string and loop number, but i used a while loop as it seems to be quicker than for.SHA-1: 0.343 //average MD5: 0.301 //average MD5 is slightly quicker on my machine anyway, ill do some indepth benchmarking in a mo. Ill test others too, apart from base64 coz its 2way. |
Is everyone using the latest PHP? and my results are real, i'd be happy to test someone elses code if they post it.
|
Somebody give me their code and I'll have myself a test!
|
Right, i just very quickly coded this little test script.
It runs 20 times, then takes the average of 20 iterations. PHP Code:
just uncomment the type of test u want to run i.e for loop etc. note because i am running PHP5 i can call microtime(true) because they changed it in php5, in php4 you need something like so: PHP Code:
|
That's much different from how i did it, i'll get back to you on that.
I started my timer, did a while loop with md5, etc.. in it then ended the time and displayed it. |
well the theory is the same (I'm guessing from how you did it) i.e.
|
I'd just like to point out that nothing you're doing involves encryption. Of the methods shown, SHA1 is the only one I'd accept to perform a hash on non-critical data.
|
Quote:
|
Quote:
|
Quote:
As far as i understand both MD5 and SHA-1 have both been deemed 'not as secure as they used to be' because or the numerous types of 'cracking' techniques and SHA-1 was compromised by a research team in China and it’s use has been discontinued by the U.S Government in favor of the SHA-2 family of hashing algorithms. I think people should start using php's hash function more, as it allows you to hash to more than just MD5 and SHA-1. |
All these methods are encryption, encryption doesn't always have to be secure. It just changes the original object into a new string which is pretty much unreadable to a normal person, in my opinion it is encryption.
|
|
thats an interesting little script that, ill have to have a prat around with that methinks.
|
| All times are GMT. The time now is 09:37 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0