I’m writing a web app that points to external links. I’m looking to create a non-sequential, non-guessable id for each document that I can use in the URL. I did the obvious thing: treating the url as a string and str#crypt on it, but that seems to choke on any non-alphanumberic characters, like the slashes, dots and underscores.
Any suggestions on the best way to solve this problem?
Thanks!
Depending on how long a string you would like you can use a few alternatives:
Note that this won’t be unguessable, you may have to combine it with some other (secret but static) data to salt the string:
Now it becomes much harder to generate this hash for someone who doesn’t know the original content and has no access to your source.