Note that an MD5 sum is not independent of the order of the words. You could however split, sort, then join to get the words in the same order each time.
Your first technique would more properly be called a checksum and is independent of character order.
Note too that 16 bits does not produce a very unique result compared with an MD5 hash which uses 128 bits. Depending on how many strings you are working with, there may be a fairly high chance that you will get identical checksums for different strings using only 16 bits.
DWIM is Perl's answer to Gödel
|