I know two methods of encryption md5(), crc32() i want to know which is the better one?
Three answers:
Ratchetr
2012-09-05 22:34:00 UTC
Neither md5 or crc32 is an encryption method. They are hashing methods.
So...if you only know md5 and crc32, then you don't know any encryption methods in PhP.
An encryption is reversible. You start with a plain text message, you encrypt it into cipher text. The cipher text should be unreadable to everyone without the key. But with the key, you can decrypt the cipher text and recover the original message.
That is not true of a hash like md5 or crc. For any given md5 (or crc) there are an infinite number of messages that will produce that hash. So you can't know which one it was (although you might be able to guess, which is a weakness in that approach).
But B108891037 is right, as a hashing function, crc32 isn't very good.
B108891037
2012-09-05 21:57:13 UTC
Based upon your need's you will choose
Only use CRC if computation resources are very tight (i.e. some embed environments) or you need to store/transport many output values and space/bandwidth is tight (as CRCs are usually 32-bit where an MD5 output is 128-bit, SHA1 160 bit, and other SHA variants up to 512 bit).
Never use CRC for security checks as a CRC is very easy to "fake".
Even for accidental error detection (rather than malicious change detection) hashes are better than a simple CRC. Partly because of the simple way a CRC is calculated (and partly because CRC values are usual shorter than common hash outputs so have a much smaller range of possible values) it is much more likely that, in a situation where there are two or more errors, one error will mask another so you end up with the same CRC despite two errors.
In short: unless you have reason not to use a decent hash algorithm, avoid simple CRCs
anonymous
2016-10-23 02:17:20 UTC
nicely the premier way may be an basic Ceaser cypher the position you replace each and every personality with yet another so say a will change into d, f will change into j etc. that is basic to do using an array. you may opposite it using an same technique. that is all a question of how imprecise you want to make the encrypted string. you may also lok on the ord() and chr() purposes as a way of encrypting it. a mixture of those 2 strategies ought to produce a sturdy technique.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.