How to generate a unique hash for a URL?

前端 未结 12 1420
时光取名叫无心
时光取名叫无心 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 09:09

    You can use UUID Class in Java to generate anything into UUID from bytes which is unique and you won't be having a problem with file lookup

    String url = http://www.google.com;
    String shortUrl = UUID.nameUUIDFromBytes("http://www.google.com".getBytes()).toString();
    

提交回复
热议问题