How can I generate a non-duplicate string using php? As shown in the end after youtube, the string 6Af6b_wyiwI (a character acceptable to the website) is displayed. What are the differences between the characters in size and wyiwi? You can also set the length of each output string, for example, 4 ~ 7. the machine will become ga79eaa09gswawe9f equivalent (... how can I use php to generate a non-duplicate string?
As the string after the end of youtube will appear: 6Af6b_wyiwI (acceptable Web site characters)
What's the difference between the size and the number of shards?
You can also set the length of each output string.
Example 4 ~ 7
This will change to ga79e aa09gsw awe9f category (this will happen every time)
Reply content:
How can I generate a non-duplicate string using php?
As the string after the end of youtube will appear: 6Af6b_wyiwI (acceptable Web site characters)
What's the difference between the size and the number of shards?
You can also set the length of each output string.
Example 4 ~ 7
This will change to ga79e aa09gsw awe9f category (this will happen every time)
We recommend that you use the timestamp, which can be encrypted by MD5 or sha1, but the length is fixed in case. you can intercept the data or customize the encryption rules. you can set the desired length. There is no possibility of repeated operations (impossible events)
If you define your own string and obtain it at random, there is a possibility of repetition (small probability event ).
If you write a url
You can also refer to segmentfault url writing
Https://segmentfault.com/q/10...
Generate a sequence of sequential growth, and convert it to a string using ascii code
Conversion between PHP 10 and 62:
echo gmp_strval(gmp_init('9876543210', 10), 62)."\n"; //AmOy42echo gmp_strval(gmp_init('AmOy42', 62), 10)."\n"; //9876543210
The above AmOy42 should be the "string" you want. In fact, it is a 62-digit number.
In the 62-digit system (10 + 26 + 26), 10 digits, 26 lower-case letters, and 26 upper-case letters are used to represent values, greatly reducing the number of digits.
9876543210 is the auto-increment ID in the database, which is unique.
In a simple way, hash algorithms such as sha256 obtain binary data (instead of a hexadecimal string) and then use base64 encoding.
Refer to the short link generation method.