+ // XOR (only works on wiegand stuff)
+ for (i = 1; i < 12; ++i)
+ rawbytes[i] ^= xorKey ;
+
+ if (g_debugMode) printf(" XOR | %s \n", sprint_hex(rawbytes, sizeof(rawbytes)));
+
+ // convert rawbytes to bits in pre
+ for (i = 0; i < 12; ++i)
+ num_to_bytebitsLSBF( rawbytes[i], 8, pre + (i*8));
+
+ if (g_debugMode) printf("\n Raw | %s \n", sprint_hex(rawbytes, sizeof(rawbytes)));
+ if (g_debugMode) printf(" Raw | %s\n", sprint_bin(pre, 64) );
+
+ // add spacer bit 0 every 4 bits, starting with index 0,
+ // 12 bytes, 24 nibbles. 24+1 extra bites. 3bytes. Ie 9bytes | 1byte xorkey, 8bytes rawdata (64bits, should be enough for a 40bit wiegand)
+ addParity(pre, guardBits+6, 64, 5, 3);
+
+ // preamble
+ guardBits[0] = 1;
+ guardBits[1] = 1;
+ guardBits[2] = 1;
+ guardBits[3] = 1;
+ guardBits[4] = 1;
+ guardBits[5] = 0;
+/* 6 B
+PRE | 0110 1101 0101 1110 0001 1101 1101 0111 1101011011010110110101101101011
+FIN | 111110 0 0110 0 1101 0 0101 0 1110 0 0001 0 1101 0 1101 0 0111 0 110100110011010011001101001100110100110000000000
+*/
+
+ if (g_debugMode) printf(" FIN | %s\n", sprint_bin(guardBits, 96) );