How short can a GUID be?

前端 未结 6 1792
离开以前
离开以前 2021-02-07 04:01

I know the standard GUIDs. Can they be made shorter? What is the theory behind it?

6条回答
  •  再見小時候
    2021-02-07 04:59

    Greg Dean's answer is correct but in order to understand how a GUID is generated and why it ought not to be shortened I would highly suggest you read the article below.

    The Old New Thing : GUIDs are globally unique, but substrings of GUIDs aren't:

    A customer needed to generate an 8-byte unique value, and their initial idea was to generate a GUID and throw away the second half, keeping the first eight bytes. They wanted to know if this was a good idea.

    No, it's not a good idea.

    The GUID generation algorithm relies on the fact that it has all 16 bytes to use to establish uniqueness, and if you throw away half of it, you lose the uniqueness.

提交回复
热议问题