YouTube URL algorithm?

后端 未结 11 1865
遇见更好的自我
遇见更好的自我 2020-12-04 09:39

How would you go about generating the unique video URL\'s that YouTube uses?

Example:

  • http://www.youtube.com/watch?v=CvUN8qg9lsk
11条回答
  •  -上瘾入骨i
    2020-12-04 10:18

    Using some non-trivial hashing function. The probability of collision is very low, depending on the function, the parameters and the input domain. Keep in mind that cryptographic hashes were specifically designed to have very low collision rates for non-random input (i.e. completely different hashes for two close-but-unequal inputs).

    This post by Jeff Attwood is a nice overview of the topic.

    And here is an online hash calculator you can play with.

提交回复
热议问题