Re: Guid question
From: Mike Margerum (mike_at_garbage.com)
Date: 03/15/05
- Next message: Wayne Niddery [TeamB]: "Re: SD Times article"
- Previous message: Wayne Niddery [TeamB]: "Re: Re:SD Times article"
- In reply to: Jon Shemitz: "Re: Guid question"
- Next in thread: Rudy Velthuis [TeamB]: "Re: Guid question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 15 Mar 2005 12:07:46 -0500
Interesting idea. thx jon.
Jon Shemitz wrote:
> Mike Margerum wrote:
>
>
>>I am using guids (strings) as id's for my objects in a system i'm
>>building. They work great but they are very large in string form (38
>>bytes). Would it be a crazy idea to use the CRC of a guid string
>>instead? that would be 4 bytes. That would still be pretty unique right?
>
>
> I agree with those who say just use the full 16-byte binary Guid.
>
> But, I recently had to write a hash routine for a Guid, and found that
> multiplying each byte together (turning 0's into 1's) made a pretty
> decent hash. I didn't do any mathematical analysis - but I did do a
> NUnit test where I'd create a new Guid, hash it, and then create and
> hash 100,000 or so other Guids without a collision.
>
> Pretty simple to code - something like
>
> int Accumulator = 1;
> foreach (byte B in ThisGuid.ToByteArray())
> Accumulator = unchecked (Accumulator * ((B != 0) ? B : 1));
>
> - which is probably a bit faster than a CRC.
>
- Next message: Wayne Niddery [TeamB]: "Re: SD Times article"
- Previous message: Wayne Niddery [TeamB]: "Re: Re:SD Times article"
- In reply to: Jon Shemitz: "Re: Guid question"
- Next in thread: Rudy Velthuis [TeamB]: "Re: Guid question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|