php: number only hash?

后端 未结 7 1980
眼角桃花
眼角桃花 2020-12-03 01:00

In php is there a way to give a unique hash from a string, but that the hash was made up from numbers only?

example:

return md5(234); // returns 098f         


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 01:27

    Try hashid.
    It hash a number into format you can define. The formats include how many character, and what character included.
    Example:
    $hashids->encode(1);
    Will return "28630" depends on your format,

提交回复
热议问题