locked
GUID to Short String and Short String to GUID RRS feed

  • Question

  • Hi,

    Is First 5 or Last 5 characters of GUID is Unique?.        

    If this is not true, please let me know the way to achieve the following functionality,

    I want to convert the GUID from 32 characters into 5 characters, and from this 5 characters I should be able to get the Original GUID. I want this functionality without interact with database and storing in any class variables.

    Please give me suggestion on this.............

    Thanks...

    • Moved by Mr. Wharty Thursday, June 28, 2012 3:16 AM Not a Training and Certification question (From:Training and Certification)
    Monday, June 18, 2012 11:42 AM

Answers

  • This is not the best forum for asking such a question, but anyway, I'll try to answer: Forget it! What you want to do cannot be done. If you take 5 characters out of 32, then you cannot get back all of the 32 characters out of the 5 you extracted. All the characters in the GUID are basically random. There was a time when part of each GUID was taken from the MAC address of one of the network interfaces in the computer, but this made the GUIDs "unsafe" so newer GUID generators no longer follow that pattern. The fact that the GUID looks like a random number from an outside point of view means that the minimum amount of storage needed to store the 128 bits of the GUID (32 hex characters) is 128 bits or 32 hex characters. You cannot compress it into fewer characters in any way that will allow you to reverse the operation.
    • Proposed as answer by Mr. Wharty Thursday, June 28, 2012 3:15 AM
    • Marked as answer by Mr. Wharty Thursday, June 28, 2012 3:16 AM
    Monday, June 18, 2012 3:13 PM

All replies

  • This is not the best forum for asking such a question, but anyway, I'll try to answer: Forget it! What you want to do cannot be done. If you take 5 characters out of 32, then you cannot get back all of the 32 characters out of the 5 you extracted. All the characters in the GUID are basically random. There was a time when part of each GUID was taken from the MAC address of one of the network interfaces in the computer, but this made the GUIDs "unsafe" so newer GUID generators no longer follow that pattern. The fact that the GUID looks like a random number from an outside point of view means that the minimum amount of storage needed to store the 128 bits of the GUID (32 hex characters) is 128 bits or 32 hex characters. You cannot compress it into fewer characters in any way that will allow you to reverse the operation.
    • Proposed as answer by Mr. Wharty Thursday, June 28, 2012 3:15 AM
    • Marked as answer by Mr. Wharty Thursday, June 28, 2012 3:16 AM
    Monday, June 18, 2012 3:13 PM
  • This is a training and certification forum.  As your question relates to neither of these, it will be moved to the Off-topic forum.

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    Twitter: @Mr_Wharty
    MC ID: Microsoft Transcript

    Thursday, June 28, 2012 3:15 AM