@@ -113,11 +113,13 @@ Future<void> handleKioskScan({
113113/// - 89:02:9e:40 (colon-separated, lowercase)
114114/// - 89 02 9e 40 (space-separated)
115115/// - 89029e40 (no separator)
116- /// - decimal BE string (e.g. "2299477568 ")
117- /// - decimal LE string (e.g. "1075381897 ")
116+ /// - decimal BE string (e.g. "2298650176 ")
117+ /// - decimal LE string (e.g. "1084097161 ")
118118///
119- /// If a user stored a decimal value in their alias, we also parse it
120- /// to hex and generate the hex variants from that.
119+ /// From a decimal input like "1084097161" (keyboard RFID reader) we produce:
120+ /// - BE hex: 40:9e:02:89 (direct byte conversion)
121+ /// - LE hex: 89:02:9e:40 (reversed — matches PCSC format)
122+ /// - plus space-separated and no-separator variants of both
121123Set <String > _buildUidVariants (String input) {
122124 final variants = < String > {};
123125 final normalized = input.trim ().toLowerCase ();
@@ -150,17 +152,28 @@ Set<String> _buildUidVariants(String input) {
150152 }
151153
152154 // If input looks like a plain decimal number, parse it to hex bytes
153- // and add those variants too (in case user stored hex but card gave decimal)
155+ // and add those variants too (in case user stored hex but card gave decimal).
156+ // We generate both BE and LE byte orders because keyboard RFID readers
157+ // typically output the LE decimal of the UID bytes.
154158 final asInt = BigInt .tryParse (normalized);
155159 if (asInt != null && asInt > BigInt .zero) {
156160 final bytes = _bigIntToBytes (asInt);
157161 if (bytes.isNotEmpty) {
158- final hexParts = bytes
162+ // Big-endian interpretation
163+ final hexBe = bytes
159164 .map ((b) => b.toRadixString (16 ).padLeft (2 , '0' ))
160165 .toList ();
161- variants.add (hexParts.join (':' ));
162- variants.add (hexParts.join (' ' ));
163- variants.add (hexParts.join ());
166+ variants.add (hexBe.join (':' ));
167+ variants.add (hexBe.join (' ' ));
168+ variants.add (hexBe.join ());
169+
170+ // Little-endian (reversed) interpretation
171+ final hexLe = bytes.reversed
172+ .map ((b) => b.toRadixString (16 ).padLeft (2 , '0' ))
173+ .toList ();
174+ variants.add (hexLe.join (':' ));
175+ variants.add (hexLe.join (' ' ));
176+ variants.add (hexLe.join ());
164177 }
165178 }
166179
0 commit comments