Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a GUID to a shorter string using 36 character alphabet 0-9 and A-Z

Tags:

guid

hex

radix

I have application where I am using printed qr codes to identify real life objects with their database records.

The database uses GUID's as primary keys (this is non-negotiable as it is an occasionally connected system).

In order to make the qr code as small as possible I am attempting to convert my 32 character hexadecimal GUID to a shorter string that takes advantage of the 36 character alphabet (0-9 and A-Z) available in alphanumeric qr codes.

The whole base conversion is going over my head, so any help is greatly appreciated.

like image 635
Andy Avatar asked Sep 16 '25 22:09

Andy


1 Answers

You could store the GUID as a byte array and convert it into Base32.

Also see this related question.

like image 72
sharptooth Avatar answered Sep 19 '25 23:09

sharptooth