How to generate a unique hash for a URL?

前端 未结 12 1416
时光取名叫无心
时光取名叫无心 2020-12-28 08:11

Given these two images from twitter.

http://a3.twimg.com/profile_images/130500759/lowres_profilepic.jpg
http://a1.twimg.com/profile_images/58079916/lowres_pr         


        
12条回答
  •  臣服心动
    2020-12-28 08:51

    A very simple approach:

    f( "http://a3.twimg.com/profile_images/130500759/" ) = a3_130500759.jpg
    f( "http://a1.twimg.com/profile_images/58079916/" )  = a1_58079916.jpg
    

    As the other parts of this URL are constant, you can use the subdomain, the last part of the query path as a unique filename.

    Don't know what could be a problem with this solution

提交回复
热议问题