+int CmdLegicCalcCrc8(const char *Cmd){
+
+ int len = strlen(Cmd);
+ if (len & 1 ) return usage_legic_calccrc8();
+
+ uint8_t *data = malloc(len);
+ if ( data == NULL ) return 1;
+
+ param_gethex(Cmd, 0, data, len );
+
+ uint32_t checksum = CRC8Legic(data, len/2);
+ PrintAndLog("Bytes: %s || CRC8: %X", sprint_hex(data, len/2), checksum );
+ free(data);
+ return 0;
+}
+
+static command_t CommandTable[] = {
+ {"help", CmdHelp, 1, "This help"},
+ {"decode", CmdLegicDecode, 0, "Display deobfuscated and decoded LEGIC RF tag data (use after hf legic reader)"},
+ {"read", CmdLegicRFRead, 0, "[offset][length] -- read bytes from a LEGIC card"},
+ {"save", CmdLegicSave, 0, "<filename> [<length>] -- Store samples"},
+ {"load", CmdLegicLoad, 0, "<filename> -- Restore samples"},
+ {"sim", CmdLegicRfSim, 0, "[phase drift [frame drift [req/resp drift]]] Start tag simulator (use after load or read)"},
+ {"write", CmdLegicRfWrite,0, "<offset> <length> -- Write sample buffer (user after load or read)"},
+ {"fill", CmdLegicRfFill, 0, "<offset> <length> <value> -- Fill/Write tag with constant value"},
+ {"crc8", CmdLegicCalcCrc8, 1, "Calculate Legic CRC8 over given hexbytes"},
+ {NULL, NULL, 0, NULL}
+};
+
+int CmdHFLegic(const char *Cmd) {
+ clearCommandBuffer();
+ CmdsParse(CommandTable, Cmd);
+ return 0;
+}
+
+int CmdHelp(const char *Cmd) {
+ CmdsHelp(CommandTable);
+ return 0;
+}
\ No newline at end of file