2 ms·
I would associate each URL with a sequential number. And express the number using base-36 (0...9 + a...z). I don't see the need to use obfuscation for this ap
by mdakin 17y ago
I would associate each URL with a sequential number. And express the number using base-36 (0...9 + a...z). I don't see the need to use obfuscation for this application but if desired I'd hash the URL + a secret and prepend that fixed-length hash to the base-36 sequential number. I'd express the hash in base-36 too.
- dagobart 17y agoWell, originally, tinyurl just went for sequential short URLs too. But as those were predictable, abuse was afoot: "Early on, the resulting URL aliases of the service were predictable, and were exploited by users to create vulgar associations. The URL aliases dick and cunt were made to redirect to the White House websites of U.S. Vice President Dick Cheney and Second Lady Lynne Cheney." Source: http://en.wikipedia.org/wiki/Tinyurl#Early_abuses http://en.wikipedia.org/wiki/Tinyurl#Early_abuses
- mdakin 17y agoInteresting... tack that hash on. :) Probably does not need to be a hash actually. A few random base-36 digits would do it. You'd just need to store the random digits with the URL in whatever sort of persistent storage system you're utilizing.