Re: Guid question

From: Mike Margerum (mike_at_garbage.com)
Date: 03/15/05


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.
>



Relevant Pages

  • Re: System.Guid
    ... issue serializing the value of what's supposed to be a guid on the client. ... How about if you change the signature to string, ... HttpContext context, HttpRequest request, HttpResponse response, Boolean& ... abortProcessing)If I change the type of parameter1 to a simple type such ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Problem with dataset crashing my app
    ... You should input check for a null guid and not even try to retrieve data where it is null.Based on my reading of your code, this value should never be null. ... Edit the binding event of the Data Grid and look for the null there, where you can supply an empty string for the cell instead, as everything is converted to string to output to the browser anyway. ... If I use the code below, but have null passed as the PostingGuid, then by the time I get to fill the dataset, I have "an object is not set to an instance of an object". ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Problem with dataset crashing my app
    ... The guid I am passing is actually a string representation of it. ... another method is to return an empty dataset when it is null. ... properly branch it (assuming this a database, like SQL Server, of course). ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Urgent - Exchange not init when reboot
    ... ExRpcConnectionCreateFlag createFlags, ConnectFlag connectFlags, String ... mailboxGuid, Guid mdbGuid, ClientIdentityInfo clientIdentity, String ... userDnAs, OpenStoreFlag openStoreFlags, CultureInfo cultureInfo, String ...
    (microsoft.public.exchange.admin)
  • Re: How to convert a GUID to CString and display it?
    ... Converts a globally unique identifier into a string of printable ... LPOLESTR lpsz, ... GUID to be converted. ... Number of characters available in the buffer indicated by lpsz. ...
    (microsoft.public.vc.mfc)

Loading