3

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.

4

4 回答 4

2

您可以将 GUID 存储为字节数组并将其转换为Base32

另请参阅此相关问题

于 2011-01-18T11:49:39.287 回答
1

我会将其转换为比 Base32 小 20% 的 Base64。转换为 base64 的库或示例代码很容易获得。base64 的唯一问题显然是字母 'a' 和 'A' 根据 base64 不同但不一定与您的数据库不同,因此如果您选择 Base64 而不是 Base32,那么您必须检查您的数据库表排序规则是正确设置。

于 2011-01-18T12:02:51.913 回答
0

全局唯一标识符 (GUID) 的值可以表示为 32 个字符的十六进制字符串,但通常存储为 128 位(16 字节)整数。

我怀疑可以存储这种 128 位值的最小可能 QR 码是指定“二进制/字节编码”(可以存储任何 8 位字节)并直接存储 16 个字节。每比特编码 1 个像素,每字节 8 个像素(加上标准开销比特)。我很确定所有其他有效的 QR 编码每比特至少使用 1 个像素,并且具有相同的标准开销。因此,您不会通过任何类型的 Base64 或 Base45 或 Base36 或 Base32 转换获得更小的 QR 码。

我见过的大多数编码 URL 的二维码都使用相同的“二进制/字节编码”来支持小写字母。在我的经验中,使用“字母数字编码”的 QR 码不太常见——当用于对 URL 进行编码时,它们会解码为全大写 URL(因为它们只能存储 0-9、A-Z 的 45 个符号 [仅大写]、空格、$、%、*、+、-、.、/、:)。“每 2 个字符 11 位”在许多情况下非常聪明,但在编码 GUID 时并没有真正的帮助。

您看过http://www.younoodle.com/startups/barcode_guidWikipedia:spime吗?

于 2012-04-27T00:16:12.613 回答
0

Storing a GUID in a QRcode as a 16 byte integer is the best way to get a small QRcode, if you find this still physically still too large, consider rendering Micro QR codes. [https://www.qrcode.com/en/codes/microqr.html] (QRcodes can't be further compressed, as they are already close to maximum entropy)

于 2019-09-14T22:01:36.763 回答