Link to home
Start Free TrialLog in
Avatar of marchent
marchentFlag for Bangladesh

asked on

Random Unique ID generate

i want to generate 64 bit random integer for my website user ID, can you tell me what would be better algorithm so that i feel every ID would be unique but random.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marchent

ASKER

DES is fine, Is there anyother algorithm which can generate random number?
Is there a problem with using a guid?
GUID is 128 bits, each generated GUID is not guaranteed to be unique, and GIUD are not random
The chance of a guid collision is only of theoretical interest.

Also ANY random number here will have a chance of duplication approx 1/2^64. Its not theoretically possible to not have this chance and be random at the same time based upon the generally accepted definition of random.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The question was posed just at that, is the only problem with 128 instead of 64 the 4 bytes of transfer or is there some other reason. Guids are kind of the defacto industry standard for the described problem. For things like long term maintenance I would probably use the Guid but thats me.

As to having no readily apparent pattern, I think that anything you do here will have a readily apparent pattern or it will have a possibility of collision. The moment you bring anything thats probabilistic into the equation you lose the assurance of no collision (you logically have to unless you are using a larger domain of results than you have in your original domain).

If you want probabilistic numbers you would probably have to check against the numbers that you have (or run some low probability of failure).

Cheers,

Greg

The pattern in a DES encryption of a sequential number would be computationally infeasible to detect.
If that is still too apparent, there are stronger encryption methods that can be used.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial