fix(qr): Revert to original 12-byte Amnezia header format

The working QR format from Amnezia app uses:
- 12-byte header: version (0x07C00100) + compressedLen + uncompressedLen
- zlib compressed JSON data

Previously I incorrectly changed this to Qt qCompress format (4-byte header).
This commit reverts to the correct Amnezia-compatible format.
This commit is contained in:
infosave2007
2026-01-24 13:26:24 +03:00
parent 45c0985ace
commit e283fdac1d
+5 -4
View File
@@ -63,15 +63,16 @@ class QrUtil
public static function encodeOldPayloadFromJson(string $jsonText): string
{
$json = self::normalizeJson($jsonText);
// Qt qCompress format: 4-byte big-endian uncompressed length + zlib compressed data
// This is what Amnezia Android's qUncompress expects
// Amnezia format: 12-byte header [version, compressed_len, uncompressed_len] + zlib compressed data
// Version 0x07C00100 is required for compatibility with Amnezia apps
$compressed = gzcompress($json, 9);
if ($compressed === false) {
throw new RuntimeException('gzcompress failed');
}
$uncompressedLen = strlen($json);
// Qt format: 4 bytes of uncompressed length (big-endian) + zlib data
$header = pack('N', $uncompressedLen);
$compressedLen = strlen($compressed) + 4; // +4 for the uncompressed length field
$version = 0x07C00100; // Amnezia magic version number
$header = pack('N3', $version, $compressedLen, $uncompressedLen);
return self::urlsafe_b64_encode($header . $compressed);
}