From 5d25096cffdfbfd8a91c108f0894959f73628579 Mon Sep 17 00:00:00 2001 From: Zion Ng Date: Wed, 10 Mar 2021 14:05:42 +0800 Subject: [PATCH] Ensure checksum is always 4 digits --- src/SgQr/Parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SgQr/Parser.php b/src/SgQr/Parser.php index ebdd1cd..53c2e5c 100644 --- a/src/SgQr/Parser.php +++ b/src/SgQr/Parser.php @@ -139,7 +139,7 @@ public function computeChecksum($text, $polynomialHex = 0x1021, $initialValue = } } - return strtoupper(dechex($result)); + return str_pad(strtoupper(dechex($result)), 4, '0', STR_PAD_LEFT); // ensure 4 chars cos result may be shorter } /**