dimanche 28 juin 2015

How to generate short, reasonably non-sequential keys in Scala (unique web links)

I'm sure someone has created a great, terse, and effective Scala function for generating short non-sequential keys suitable for use in web links. I'd like the keys to be hard to guess sequentially... I don't want someone just "browsing" through the links – but, hitting on one randomly is not a big deal.

There are a few related posts (this one and this other one), but they don't really address the problem (and they are in the wrong languages). The idea is to make seemingly random, reasonably short URL keys. Something like Vimeo or Youtube short links would be fine, but not too short (http://watever.com/abc is too easy to guess/browse) and not too long (http://ift.tt/1eSYP1x is just too long). A happy medium would be most desirable: http://ift.tt/1eSYOL2.

They keys will ultimately be stored in a relational database, so I have the option of checking for uniqueness, and retrying until I "get lucky."

Any ideas? Or hopefully a slick little algorithm?




Aucun commentaire:

Enregistrer un commentaire