LRC算法的C实现
1.1、LRC.h
#ifndef LRC_H
#define LRC_H

    #include <stdlib.h>

    #ifdef __cplusplus
        extern "C" {
    #endif

    unsigned char LRC(unsigned char *bytes, size_t bytesLength);

    #ifdef __cplusplus
        }
    #endif
#endif
1.2、LRC.c
#include "LRC.h"

unsigned char LRC(unsigned char* bytes, size_t bytesLength) {
    unsigned char byte = 0;
    for (size_t i = 0; i < bytesLength; i++) {
        byte += bytes[i];
        byte &= 0xFF;
    }
    return 256 - byte;
}