Search code examples
character-encodingbase64guid

Shortening a GUID


We generate a GUID for a document and need to include the GUID in a barcode (Type 29 2D) which is C40 encoded and has the following restrictions.

Can be a max length of 25 characters Can only use UPPER Alphanumerical characters, no special characters.

I had thought of converting to Base64 but that uses special characters.


Solution

  • This article exemplifies using base64 encoding to get a 22 character long result. https://www.codeproject.com/Tips/1236704/Reducing-the-string-Length-of-a-Guid

    It also discusses that == could possibly be omitted in special cases. So a bar code with the standard ending implied could be a solution.