How to create a unique ID, such as an order ID, that will be shown to users

Asked 2 years ago, Updated 2 years ago, 40 views

If you want a unique ID inside the program, you will probably use UUID a lot, but
If the number of digits is 32 and you show it to the user, it seems a little too complicated.
In fact, the order ID you can get when you purchase from the EC site doesn't look like a UUID.

What algorithms are used to generate order IDs (unique IDs) of 10-15 digits?

algorithm

2022-09-30 17:05

2 Answers

Nice to meet you.Hello.

As far as I know, there are many cases where order numbers are auto-incorporated through database functions.In some cases, the starting number is shifted from one division to another, or the first few digits are used for business purposes.The old system starts with 1 and the new system starts with 2...If you use the product ID of the EC site, there may be requests such as making the department known by the ID.In the end, it depends on the content of the company and business, and I think it is important to design individual numbers that are convenient for the operation by coordinating with the relevant places.


2022-09-30 17:05

For example, in the URL of Coco jSO, the article number is probably the post number obtained by autoinclement.
If you don't think there's any art in your own EC site, the result of passing the post number and order number (the result of adding the appropriate sugar) through the hash function selected from md5 and sha (a few letters from the beginning)

Since it can be determined that cryptographic safety is not necessary for just article numbers, it is okay to create an Ore appropriate conversion function even if it is not a cryptographic hash function (reversible conversion is not a problem).

If you choose an irreversible conversion function, it is highly likely that you will find it difficult if you do not include the conversion results in the database.


2022-09-30 17:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.