I have to generate random (but unique) identifiers for customers for an eLearning application. This identifier also has to be input into another dependent system’s database, which is a varchar(16). They must be unique, so no two records can have the same id.
Previously, I’ve been using the following expression:
var customerId = "L" + DateTime.Now.Subtract(new DateTime(2019, 1, 1, 0, 0, 0, 0, DateTimeKind.Local)).TotalMilliseconds;
However, I just recently realized that this usually comes out to about 18-19 characters.
Does anyone have any suggestions for a better way I can accomplish this within the 16 character limit?