The code
if(str1 == "abc") {}
can be converted to
if(hash(str1) == 0x8732e) {} // assume hash("abc") == 0x8732e
to obfuscate the code.
But they are not equivalent when hash collision occurs; e.g., another string xyz
's hash value is the same as abc
.
That is true theoretically. But is it an issue in real-life when the method above is used to obfuscate code? Is it a well accepted obfuscation method?
Edit: after a little research, I guess what I need is a one-way collision-free string transformation function, as I don't care the length of the output. Any suggestions? Any mature implementations?