Convert 32-char md5 string to integer

后端 未结 5 706
情深已故
情深已故 2021-01-01 19:36

What\'s the most efficient way to convert an md5 hash to a unique integer to perform a modulus operation?

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-01 20:04

    There is more data in a MD5 than will fit in even a 64b integer, so there's no way (without knowing what platform you are using) to get a unique integer. You can get a somewhat unique one by converting the hex version to several integers worth of data then combining them (addition or multiplication). How exactly you would go about that depends on what language you are using though.

    Alot of language's will implement either an unpack or sscanf function, which are good places to start looking.

提交回复
热议问题