パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.0.0

crclib

Dart コンバーターとしての巡回冗長検査 (CRC) ルーチンのコレクション。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
17.6万
いいね数
16
Pub ポイント
140

パッケージをインストール

flutter pub add crclib

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

crclib は、データの整合性検証を効率的に行うために設計された、巡回冗長チェック(CRC)ルーチンのコレクションをコンバーターとして提供する Dart パッケージです。複数の CRC アルゴリズムをサポートし、Android、iOS、Web、macOS、Windows、Linux の Flutter アプリケーションにシームレスに統合できます。ファイル転送、ネットワーク通信、組み込みシステムにおけるデータの一貫性の検証に最適です。最小限のオーバーヘッドと簡単な使い方により、crclib は開発者が堅牢なチェックサム検証を簡単に実装できるようにします。

用途

  • ファイル転送におけるデータ整合性チェック
  • ネットワークパケット検証
  • 埋め込みシステムデータ検証
  • ファームウェア更新のチェックサム生成
  • リアルタイムデータストリームの整合性
  • クロスプラットフォームの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 件

ソースリポジトリ

このパッケージを使用しているプロジェクト