Represent MD5 hash as an integer

前端 未结 8 1912
Happy的楠姐
Happy的楠姐 2021-02-05 09:42

In my user database table, I take the MD5 hash of the email address of a user as the id.

Example: email(example@example.org) = id(d41d8cd98f00b204e9800998ecf8427e)

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-05 10:26

    what about:

    $float = hexdec(md5('string'));
    

    or

    $int = (integer) (substr(hexdec(md5('string')),0,9)*100000000);
    

    Definitely bigger chances for collision but still good enaugh to use instead of hash in DB though?

提交回复
热议问题