O
Omatase
I need to generate an account number, the account number needs to be
unique. Currently I am generating it with the following fields:
ClientReferenceNumber (guaranteed to be unique in the client's system)
and Source (unique in my system).
The ClientReferenceNumber can be anywhere between 6 and 10 digits long
and the Source can also be differing lengths (it's a 5 character
string for our first client) but I want the hash algorithm to generate
a number of equal length each time. I don't know if this is something
I can only guarantee with a pad statement, or if I can just build that
in to the algorithm. I also need the generated hash to be unique,
which should be simple given that the input is guaranteed unique. It
is also a requirement that the hash not resemble the original input.
My questions are:
What is the best way to do this?
I have this code
long hash = clientReferenceNumber + client.ToString().GetHashCode();
I am pretty sure that will be guaranteed unique, but I don't know
exactly what GetHashCode() is doing to my string. I also don't know
what length ranges I should expect to get back.
Thanks
unique. Currently I am generating it with the following fields:
ClientReferenceNumber (guaranteed to be unique in the client's system)
and Source (unique in my system).
The ClientReferenceNumber can be anywhere between 6 and 10 digits long
and the Source can also be differing lengths (it's a 5 character
string for our first client) but I want the hash algorithm to generate
a number of equal length each time. I don't know if this is something
I can only guarantee with a pad statement, or if I can just build that
in to the algorithm. I also need the generated hash to be unique,
which should be simple given that the input is guaranteed unique. It
is also a requirement that the hash not resemble the original input.
My questions are:
What is the best way to do this?
I have this code
long hash = clientReferenceNumber + client.ToString().GetHashCode();
I am pretty sure that will be guaranteed unique, but I don't know
exactly what GetHashCode() is doing to my string. I also don't know
what length ranges I should expect to get back.
Thanks