CRC관련 함수나 라이브러리 정보 요청

seungogi의 이미지

CRC 연산을 해야 하는데 필요한 함수나 라이브러리가 있을까요?
함수를 완전 작성하기에는 알고리즘을 이해하기가 어렵고 해서
CRC8로 된것을 분석하는데 필요해서요

Prentice의 이미지

happyjun의 이미지

사용 언어가 C++ 이면 boost::crc_optimal<> 를 사용하세요.

http://boost.org/libs/crc/index.html

예제 입니다.

#include <boost/crc.hpp>      // for boost::crc_basic, boost::crc_optimal
#include <boost/cstdint.hpp>  // for boost::uint16_t

#include <algorithm>  // for std::for_each
#include <cassert>    // for assert
#include <cstddef>    // for std::size_t
#include <iostream>   // for std::cout
#include <ostream>    // for std::endl


// Main function
int
main ()
{
    // This is "123456789" in ASCII
    unsigned char const  data[] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
     0x38, 0x39 };
    std::size_t const    data_len = sizeof( data ) / sizeof( data[0] );

    // The expected CRC for the given data
    boost::uint16_t const  expected = 0x29B1;

    // Simulate CRC-CCITT
    boost::crc_basic<16>  crc_ccitt1( 0x1021, 0xFFFF, 0, false, false );
    crc_ccitt1.process_bytes( data, data_len );
    assert( crc_ccitt1.checksum() == expected );

    // Repeat with the optimal version (assuming a 16-bit type exists)
    boost::crc_optimal<16, 0x1021, 0xFFFF, 0, false, false>  crc_ccitt2;
    crc_ccitt2 = std::for_each( data, data + data_len, crc_ccitt2 );
    assert( crc_ccitt2() == expected );

    std::cout << "All tests passed." << std::endl;
    return 0;
}

----------------------------------------
http://moim.at
http://mkhq.co.kr

익명 사용자의 이미지

사용언어게 Verilog라면 ftp://ftp.rfc-editor.org/in-notes/rfc3385.txt