How does php generate a machine code?

Source: Internet
Author: User
How does php generate a machine code, which has a unique value on a client and does not repeat similar mac addresses? in this way, each machine can only be registered with a single one, preventing php from generating a machine code, the unique value of a client does not repeat similar mac addresses, so that each machine can only register one, preventing registration by refreshing

Reply content:

How does php generate a machine code, which has a unique value on a client and does not repeat similar mac addresses? in this way, each machine can only be registered with one account, preventing malicious registration.

We recommend that you do not use this unique identification number on the service end. What I have doneappClient interfaces, whether connectedIOSOrAndroidThe client generates a uniqueTokenTo our server, we only need to receive the recognition. There is no need for us to produce. If you have to perform unique generation on the server, usePHPBuilt-in functionsuniqid()To produce, this can be accurate to the subtle enough, you can add some parameters on your own, hope to help you

This depends on the specific situation. if the server is in a cluster, the server ip address, process id, and timestamp can be used.

base_convert(ip2long($_SERVER['REMOTE_ADDR']),10,36).'-'.getmypid().'-'.base_convert(microtime(true)*1000 - strtotime('2016-06-07 18:00:00')*1000,10,36)

It is a long and messy cluster. if multiple clusters have the same internal ip segments, it will not work. The advantage is that each server is generated independently.

In addition, redis auto-increment and mysql auto-increment can also be achieved. these solutions seem simple and difficult to maintain, such as redis failure and how to restore auto-increment fields.

It is generated by the client and a 6-byte copy mac address is randomly generated. Basically, it will not be repeated and can be found in the keychain.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.