What do you mean by a 12 digit guid? A guid (see here http://en.wikipedia.org/wiki/Guid or also here http://en.wikipedia.org/wiki/UUID) is a 16 byte number that is typically
represented by a sequence of 32 characters, representing the 16 bytes in
hexadecimal notation. Some dashes are thrown in for good measure...
So what is it that you want to create? A 12 character random string?
Thanks for reply, I really appreciate it.
You are right, what I want is to create a random string that is 12
digit length, it has to be unique and I have no idea on how to do this.
Take a look at the system.random class. There is a method there that will
fill a byte array with random bytes. As for uniqueness, you'll need to test
for that yourself.
Is that what you're looking for? If you need to manually create a GUID I
have that code around somewhere. There's an algorithm you must follow, and
it's much easier to use the built-in guid class.
What about using the same format as a standard Guid.... Create a 12 Byte
array, and just increment the values in them (Assuming you will have a single
central place where you create these "Guids" and then converting the result
to Hex since each byte would have a numeric value of something between 0 and
255.
Another option would be to take the machine name and the date and time down
to the millisecond and combining that into a 12 byte array before doing the
hex conversion. (Just make sure that you application can then not create more
than one "Guid" per millisecond. Combining that with a random number may sort
you out, but you will still not be able to guarantee uniqueness, but you’ll
probably be close enough. All depends how deep you want to go.
Someone mentioned something about looking at the security namespace and (I'm
guessing) look at some hashing... but then, what are you going to hash.
Anyway, hope my ramblings help at least a little bit.
David
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.