PHP: Short id like Youtube, with salt

前端 未结 2 1335
夕颜
夕颜 2021-02-06 09:56

I need to encode/encrypt database ids and append them to my URLs. Security is not an issue I am trying to deal with, but I am looking for something with moderate security. The m

相关标签:
2条回答
  • 2021-02-06 10:44

    If you want to make the numerical id unguessable from the string, you can use a salt. You should be able to get the id back without collisions. The post Create short IDs with PHP - Like Youtube or TinyURL by Kevin van Zonneveld is a good start. At any rate, check for uniqueness.

    0 讨论(0)
  • 2021-02-06 10:59

    Could you not just use PHP's uniqid function to generate a faux-random string from the current timestamp? Then save this alpha-numeric string in the video record at upload time.

    0 讨论(0)
提交回复
热议问题