shortest encoding for Guid for use in a URL

前端 未结 2 1593
轮回少年
轮回少年 2021-01-11 09:43

Mad Kristensen got one down to 00amyWGct0y_ze4lIsj2Mw

Can it go smaller than that?

相关标签:
2条回答
  • 2021-01-11 10:25

    Looks like there are only 73 characters that can be used unescaped in a URL. IF that's the case, you could convert the 128-bit number to base 73, and have a 21 character URL.

    IF you can find 85 legal characters, you can get down to a 20 character URL.

    0 讨论(0)
  • 2021-01-11 10:36

    A GUID looks like this c9a646d3-9c61-4cb7-bfcd-ee2522c8f633 - that's 32 hex digits, each encoding 4 bits, so 128 bits in total

    A base64 encoding uses 6 bits per symbol, which is easy to achieve with URL safe chars to give a 22 char encoded string. As others have noted, you could with with 73 url safe symbols and encoded as a base 73 number to give 21 chars.

    0 讨论(0)
提交回复
热议问题