What is the string length of a GUID?

后端 未结 7 812
故里飘歌
故里飘歌 2020-11-29 15:15

I want to create a varchar column in SQL that should contain N\'guid\' while guid is a generated GUID by .NET (Guid.NewGuid) - class System.Guid.

7条回答
  •  抹茶落季
    2020-11-29 15:36

    GUIDs are 128bits, or

    0 through ffffffffffffffffffffffffffffffff (hex) or 
    0 through 340282366920938463463374607431768211455 (decimal) or 
    0 through 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 (binary, base 2) or 
    0 through 91"

    So yes, min 20 characters long, which is actually wasting more than 4.25 bits, so you can be just as efficient using smaller bases than 95 as well; base 85 being the smallest possible one that still fits into 20 chars:

    0 through -r54lj%NUUO[Hi$c2ym0 (base 85, using 0-9A-Za-z!"#$%&'()*+,- chars)
    

    :-)

提交回复
热议问题