Unique key generation

后端 未结 13 2231
一个人的身影
一个人的身影 2020-12-03 05:53

I looking for a way, specifically in PHP that I will be guaranteed to always get a unique key.

I have done the following:

strtolower(substr(crypt(tim         


        
13条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 06:17

    Any algorithm will result in duplicates.

    Therefore, might I suggest that you use your existing algorithm* and simply check for duplicates?

    *Slight addition: If uniqid() can be non-unique based on time, also include a global counter that you increment after every invocation. That way something is different even in the same microsecond.

提交回复
热议问题