패키지, 저장소 및 앱 카테고리 검색

패키지 상세v3.0.0

crclib

Dart 변환기로 사용되는 순환 중복 검사(CRC) 루틴 모음입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
16.2만
좋아요
16
Pub 점수
140

패키지 설치

flutter pub add crclib

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

crclib은 데이터 무결성 검증을 위한 효율적인 방법으로 설계된 Dart 패키지로, 순환 중복 검사(CRC) 루틴의 컬렉션을 변환기 형태로 제공합니다. 다양한 CRC 알고리즘을 지원하며 Android, iOS, Web, macOS, Windows, Linux에서 동작하는 Flutter 애플리케이션에 원활하게 통합됩니다. 파일 전송, 네트워크 통신, 임베디드 시스템에서의 데이터 일관성 검증에 이상적입니다. 최소한의 오버헤드와 간단한 사용법을 통해 개발자들이 강력한 체크섬 검증을 쉽게 구현할 수 있도록 도와줍니다.

사용 사례

  • 파일 전송 중 데이터 무결성 검사
  • 네트워크 패킷 검증
  • 임베디드 시스템 데이터 검증
  • 펌웨어 업데이트를 위한 체크섬 생성
  • 실시간 데이터 스트림 무결성
  • 크로스 플랫폼 CRC 계산

주요 기능

  • 여러 CRC 알고리즘을 지원합니다
  • 경량이고 빠른 변환기
  • 크로스 플랫폼 호환성
  • 간단한 API 통합
  • 내장된 테스트 케이스
  • 확장 가능한 알고리즘 설계

적합한 대상

  • 신뢰할 수 있는 CRC 검증이 필요한 개발자
  • 데이터 일관성 검사를 필요로 하는 애플리케이션
  • 정합성 요구 사항이 있는 크로스 플랫폼 프로젝트
  • 펌웨어 및 임베디드 소프트웨어 개발
  • 네트워크 프로토콜 구현

고려 사항

  • 사용 사례에 맞는 올바른 CRC 알고리즘 선택을 보장하세요
  • 처리 전에 입력 데이터 형식을 확인하세요
  • 암호 해시에 적합하지 않습니다
  • 대규모 데이터 스트림에 대한 성능 영향
  • CRC 전용 사용 사례에 한정
  • 바이트 배열의 주의 깊은 처리가 필요합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Dart crclib

This is not an official Google product.

Generic CRC calculations as Dart converters and some common algorithms.

To calculate the CRC value of any message

The easiest way to use this library is to call convert on the instance of the desired CRC routine.

  Crc32Xz().convert(utf8.encode('123456789')) == 0xCBF43926

Another supported use case is as stream transformers.

  File(...).openRead().transform(Crc32Xz()).single.then(...)

Instead of using predefined classes, it is also possible to construct a customized CRC function with ParametricCrc class. For a list of known CRC routines, check out https://reveng.sourceforge.io/crc-catalogue/all.htm.

TODO:

  1. inputReflected and outputReflected can be different, see CRC-12/UMTS.
  2. Bit-level checksums (including non-multiple-of-8 checksums).

To flip bits to obtain desired CRC values

With CrcFlipper, one can call flipWithData or flipWithValue depending on whether they have access to the message, or only its calculated CRC value. The snippet below is taken from test/flipper_test.dart.

      var inputMessage =
          'flipping lowercases to uppercases like mama pig making hot pancakes '
          'for daddy pig in peppa pig cartoon';
      // Mark the lower/upper-case bit in each character.
      // 0x61 = 'a' = 0110 0001
      //                | <-- 5th bit, zero-indexed
      // 0x41 = 'A' = 0100 0001
      var positions = inputMessage.codeUnits
          .asMap()
          .entries
          .where((e) => e.value >= 0x61 && e.value < 0x61 + 26)
          .map((e) => e.key * 8 + 5)
          .toSet();
      var flipper = CrcFlipper(Crc64());
      var solution = flipper.flipWithData(inputMessage.codeUnits, positions,
          CrcValue(BigInt.parse('DEADBEEFCAFEBABE', radix: 16)))!;
      var tmp = List.of(inputMessage.codeUnits, growable: false);
      solution.forEach((bitPosition) {
        var mask = 1 << (bitPosition % 8);
        tmp[bitPosition ~/ 8] ^= mask;
      });
      var outputMessage = String.fromCharCodes(tmp);
      expect(
          outputMessage,
          'flIPpiNG LOWErcAsEs To uPpERcaseS LIkE mAmA Pig mAKInG hOT paNcAKEs '
          'For DAdDY pig in peppa pig cartoon');

The detailed algorithm is documented in flipping_algorithm.md.

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트