It basically generates a hash based upon a timestamp using an incremented seed value, until it's able to create a HASH ending with x number of trailing zeros, at which point it's got a value token.
Server side needs to be implemented specifically for each backend, but it should be a no-brainer for most. The point is the algorithm and the idea ...
You can probably cycle through a couple million milliseconds in the various timestamps involved to get a large selection of hashes to pick from without making your commit stand out.
Hasher. Not only does it perform all kinds of hashing, but it also converts unix timestamps, numbers between bases, a bunch of string conversions AND some URL friendly conversions as well.
Other than the developer toolbar, it's the tool I use the most:
Feels like you could just concatenate and hash the 4 values with MD5 and store the hash and time.
Edit: I guess concatenate with a delimiter if you're worried about false positives with the concat. But it does read like a cache of "I've seen this before". Doing it this way would be compact and indexed well.
You can also include an extra random number in the hash, and require that within the window of acceptable timestamps the random numbers have to be unique.
By the way, be aware than hash(string1 + string2) constructions are often vulnerable. hash(hash(string1) + string2) is better for most hashes, I believe. But you shouldn't roll these primitives yourself, either. Just use a proper library.
The script is able to set 5 digits, not 4. The prefixes in the examples are actually 0001a, 0002a, etc. I added the trailing "a" to make the numbers more readable. Otherwise you would get hashes like 00015... which would look awkward. So I'm using the "a" as a kind of separator.
Also, the script refuses to change timestamps by more than 30 minutes. So changing only the committer timestamp would allow you to set only 2-3 hash digits. That's why I'm also changing the author timestamp, which leads to enough possible combinations to set about 5 hash digits. (Unless you're unlucky, because there's always a rest possibility for failure in this kind of algorithms.)
BTW, this program has been inspired by BitCoin's proof of work concept.
reply