15

Mads Kristensen got one down to 00amyWGct0y_ze4lIsj2Mw

Can it go smaller than that?

keuleJ
  • 3,418
  • 4
  • 30
  • 51
mcintyre321
  • 12,996
  • 8
  • 66
  • 103

2 Answers2

12

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.

retracile
  • 12,167
  • 4
  • 35
  • 42
  • So we're saving 9 characters on the URL? I find it actually easier to read/recite the hexadecimal than something like 00amyWGct0y_ze4lIsj2Mw – hometoast Aug 14 '09 at 17:36
  • 1
    @hometoast: Yeah, well, that didn't seem to be a constraint for the OP. ;) – retracile Aug 14 '09 at 18:07
  • 1
    I used an Ascii85 encoding for writing a Guid to a database column in 20 ASCII characters. I've posted the C# code in case it is useful. The specific character set may be different for a URL encoding, but you can pick whichever characters suit your application. It's available here: http://stackoverflow.com/questions/2827627/what-is-the-most-efficient-way-to-encode-an-arbitrary-guid-into-readable-ascii-3/4211088#4211088 – sheikhjabootie Nov 18 '10 at 02:28
  • 1
    I'm not sure where you're getting the 73 number from -- in http://tools.ietf.org/html/rfc3986#section-2.3 there are only 66 unreserved chars: 'A-Z', 'a-z', '0-9', '-', '.', '_', and '~'. What are the other 7 characters? – slacy Dec 18 '12 at 22:32
  • 3
    @slacy: From the page linked; it lists `A-Za-z0-9` and `$-_.+!*'(),`, drawn from RFC 1738 section 2.2. Looks like RFC 3986 that you referenced updates RFC 1738. The 7 characters `$+!*(),` appear in RFC 3986 section 2.2 as reserved characters as sub-delimiters. So those 7 characters came from 1994-2005, and it's now 66 characters as of 2005. – retracile Dec 28 '12 at 03:03
5

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.

Paul Dixon
  • 295,876
  • 54
  • 310
  • 348