lundi 6 novembre 2017

To or not to hash Ids for web-purpose

there are several discussions out there about how to generate unique and url friendly string-based IDs, for example:

And there are many sites which use this approach, like imgur.com, where posts are adressed by a hash instead an int (for example: http://ift.tt/2zl6tPU)

I have 2 questions:

  1. What are the reasons for using hashes instead of Integer, which is unique if you increment it? Are there some security issues related to that? Or is it, because incrementing an Integer becomes bigger and bigger?
  2. How should the database be designed? Generating and storing the hash as the primary key? Using an int-based ID and storing the hash in another column? Or maybe just using an int-based ID and encode/decode it?

Thank you very much in advance.




Aucun commentaire:

Enregistrer un commentaire