Shortest hash in python to name cache files

后端 未结 8 653
春和景丽
春和景丽 2020-12-23 22:45

What is the shortest hash (in filename-usable form, like a hexdigest) available in python? My application wants to save cache files for some objects. The objects mu

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-23 23:17

    You can make any hash you like shorter by simply truncating it. md5 is always 32 hex digits, but an arbitrary substring of it (or any other hash) has the proper qualities of a hash: equal values produce equal hashes, and the values are spread around a bunch.

提交回复
热议问题