Guessing the hash function?
algorithm, hash
Solution
The only way to derive a hash function from data is through brute force, perhaps combined with some cleverness. There are an infinite number of hash functions, and the good ones perform what is essentially one-way encryption, so it's a question of trial and error.
It's practically irrelevant that your function converts 32-character strings into 5-character hashes; the output is probably truncated. For fun, here are some perfectly legitimate examples, the last 3 of which are cryptographically terrible:
- Use the MD5 hashing algorithm, which generates a 16-character hash, and use the 10th through the 14th characters.
- Use the SHA-1 algorithm and take the last 5 characters.
- If the input string is alphabetic, use the simple substitution `A=1`, `B=2`, `C=3`, ... and take the first 5 digits.
- Find each character on your keyboard, measure its distance from the left edge in millimeters, and use every other digit, in reverse order, starting with the last one.
- Create a stackoverflow user whose name is the 32-bit string, divide 113 by the corresponding user ID number, and take the first 5 digits after the decimal. (But don't tell 'em I told you to do it!)
Problem
I'd like to know which algorithm is employed. I strongly assume it's something simple and hopefully common. There's no lag in generating the results, for instance. Input: any string Output: 5 hex characters (0-F) I have access to as many keys and results as I wish, but I don't know how exactly I could harness this to attack the function. Is there any method? If I knew any functions that converted to 5-chars to start with then I might be able to brute force for a salt or something. I know for example that: a=06a07 b=bfbb5 c=63447 (in case you have something in mind) In normal use it converts random 32-char strings into 5-char strings.