Skip to content

Instantly share code, notes, and snippets.

@Wriar
Created April 9, 2025 20:14
Show Gist options
  • Select an option

  • Save Wriar/51108d9e68d4cc6454ad403394111fc1 to your computer and use it in GitHub Desktop.

Select an option

Save Wriar/51108d9e68d4cc6454ad403394111fc1 to your computer and use it in GitHub Desktop.
HID Wiegand Keypad Bit Decoder
//Translates the raw input bits from a HID keypad reader to decimal.
int keypadBitToInteger(String inputBits) {
int decimalValue = 0;
int length = inputBits.length();
for (int i = 0; i < length; i++) {
char bit = inputBits.charAt(i);
if (bit == '1') {
decimalValue = decimalValue * 2 + 1;
} else if (bit == '0') {
decimalValue = decimalValue * 2;
} else {
return -1; //Or whatever error code u want TBD
}
}
return decimalValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment