473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

To create a 12 digit guid?

Trying to create a 12 digit "guid", but have no idea on how to, anyone
please have any thought? Thanks in advance.

Jan 2 '07 #1
9 6735
Hello twang090,
>Trying to create a 12 digit "guid", but have no idea on how to, anyone
please have any thought? Thanks in advance.
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?
Oliver Sturm
--
http://www.sturmnet.org/blog
Jan 2 '07 #2
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.
Any idea? Many thanks.
Oliver Sturm wrote:
Hello twang090,
Trying to create a 12 digit "guid", but have no idea on how to, anyone
please have any thought? Thanks in advance.

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?
Oliver Sturm
--
http://www.sturmnet.org/blog
Jan 2 '07 #3
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.

Mike Ober.

<tw******@gmail.comwrote in message
news:11**********************@n51g2000cwc.googlegr oups.com...
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.
Any idea? Many thanks.
Oliver Sturm wrote:
>Hello twang090,
>Trying to create a 12 digit "guid", but have no idea on how to, anyone
please have any thought? Thanks in advance.

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?
Oliver Sturm
--
http://www.sturmnet.org/blog

Jan 3 '07 #4
JR
Try System.Security.Cryptography.RNGCryptoServiceProvi der class

JR

"Michael D. Ober" <obermd.@.alum.mit.edu.no.spamwrote in message
news:hP*****************@newsread1.news.pas.earthl ink.net...
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.

Mike Ober.

<tw******@gmail.comwrote in message
news:11**********************@n51g2000cwc.googlegr oups.com...
>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.
Any idea? Many thanks.
Oliver Sturm wrote:
>>Hello twang090,

Trying to create a 12 digit "guid", but have no idea on how to, anyone
please have any thought? Thanks in advance.

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?
Oliver Sturm
--
http://www.sturmnet.org/blog


Jan 3 '07 #5
<tw******@gmail.comwrote in message
news:11**********************@i12g2000cwa.googlegr oups.com...
Trying to create a 12 digit "guid", but have no idea on how to, anyone
please have any thought? Thanks in advance.
Guid g = System.Guid.NewGuid();

string s= System.Guid.NewGuid().ToString();

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.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise, MVP C#
http://www.coversant.net/blogs/cmullins
Jan 3 '07 #6
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

"tw******@gmail.com" wrote:
Trying to create a 12 digit "guid", but have no idea on how to, anyone
please have any thought? Thanks in advance.

Jan 4 '07 #7
Skanda <Sk****@discussions.microsoft.comwrote:
Use the method System.Guid.NewGuid()
In what way does that create a 12-digit "guid"? GUIDs are 128 bits...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 10 '07 #8
>>Use the method System.Guid.NewGuid()

In what way does that create a 12-digit "guid"? GUIDs are 128 bits...
Am I the only one who can see the part of the thread where this has
already been discussed, more than a week ago?

:-)
Oliver Sturm
--
http://www.sturmnet.org/blog
Jan 10 '07 #9
Oliver Sturm <ol****@sturmnet.orgwrote:
>
>Use the method System.Guid.NewGuid()
In what way does that create a 12-digit "guid"? GUIDs are 128 bits...

Am I the only one who can see the part of the thread where this has
already been discussed, more than a week ago?
Nope - I was just wondering what Skanda thought benefit he/she was
providing...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 10 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
15
by: Brian Rogers | last post by:
Hello everyone, I apologize for the cross and re-post, but I am still searching for an answer. Why can C++ can create this object, but C# can't? I am trying to create an instance of the...
9
by: Bill | last post by:
I need to create a temporary file on the file system. I have over 5000 users What's the best method to ensure uniqueness Thank Bill
7
by: ESPNSTI | last post by:
Hi, I'd like to create a Guid constant and the following doesn't work (Cannot implicitly convert type 'string' to 'System.Guid') : public const Guid MyGuid =...
1
by: Grey | last post by:
how to create a GUID from ASP.NET??? Is it possible to use this ID as primary key in createing DB record?? Million Thanks..
24
by: M O J O | last post by:
Hi, Instead of doing this.... Public Class Form1 Public Shared Sub CreateAndShow() Dim f As New Form1 f.Show() End Sub
7
by: =?Utf-8?B?SlA=?= | last post by:
I need to design a WS that will after authenicating the user, create a cookie on the users PC that made the request. All the code I keep finding is how to get a WS to read a cookie, I need it to...
0
by: yrogirg | last post by:
Actually, I need utf-8 to utf-8 encoding which would change the text to another keyboard layout (e.g. from english to russian ghbdtn -> ÐÒÉ×ÅÔ) and would not affect other symbols. I`m totally...
5
by: Andy B | last post by:
I am making a web application that would randomly create an activation code and put it in a database. The web application would then send it in an email to the user with a link to go to and enter...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.