-
hashing a string
Hello i was wondering if the following code is easily reversible:
PHP Code:
string jhash(string str)
{
unsigned int i;
for(i = 0; i < str.length()-1; i++)
str[i] >>= str[i+1];
for(i = 1; i < str.length(); i++)
str[i] += str[i-1];
for(i = 0; i < str.length()-1; i++)
str[i] <<= str[i+1];
for(i = 1; i < str.length(); i++)
str[i] ^= str[i-1];
return str;
}
Thanks for your help.
:)
-
No its not reversable at all.
Using the shift operator >> loses bits.
If you remove the 2 loops that use shift operators then the hashing can be reversed.
-
ok thanks
alright, i just wanted to make a quick unreversible string hash for use in an application i'm working on : )