Answer the question
In order to leave comments, you need to log in
Order code generation?
Hello.
On the site, users place orders for goods and it is necessary to generate unique identifiers for each order in the following format:
(Letter)(Letter)(Number)(Number)(Number)
Answer the question
In order to leave comments, you need to log in
Generate these codes ahead of time and the status of the code is used or free, and then to mongo request to get a free limit of 1 update used, but this solution seems wild to me.
According to your option 1) - The required information capacity (19 bits) is too small to deal with collisions, because they obey the birthday paradox - after 700 orders you have a 50% chance of having the first collision.
According to your option 2) - get a counter and encrypt it with some fixed key with a block size of 19 bits. Encryption is a bijective operation - it will guarantee the uniqueness of the ciphertexts.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question