pax_global_header00006660000000000000000000000064151765575200014527gustar00rootroot0000000000000052 comment=65580dc67af54f5cab5d9ea4e0810d011bc136f5 fastcrc-0.3.6/000077500000000000000000000000001517655752000131625ustar00rootroot00000000000000fastcrc-0.3.6/.github/000077500000000000000000000000001517655752000145225ustar00rootroot00000000000000fastcrc-0.3.6/.github/dependabot.yml000066400000000000000000000011031517655752000173450ustar00rootroot00000000000000# Keep GitHub Actions up to date with GitHub's Dependabot... # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem version: 2 updates: - package-ecosystem: github-actions directory: / groups: github-actions: patterns: - "*" # Group all Actions updates into a single larger pull request schedule: interval: weekly fastcrc-0.3.6/.github/workflows/000077500000000000000000000000001517655752000165575ustar00rootroot00000000000000fastcrc-0.3.6/.github/workflows/ci.yml000066400000000000000000000130041517655752000176730ustar00rootroot00000000000000# This file is autogenerated by maturin v1.9.6 # To update, run # # maturin generate-ci github # name: CI on: push: branches: - main - master tags: - "*" pull_request: workflow_dispatch: permissions: contents: read jobs: linux: runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: ubuntu-22.04 target: x86_64 - runner: ubuntu-22.04 target: x86 - runner: ubuntu-22.04 target: aarch64 - runner: ubuntu-22.04 target: armv7 - runner: ubuntu-22.04 target: s390x - runner: ubuntu-22.04 target: ppc64le - runner: ubuntu-22.04 target: riscv64gc-unknown-linux-gnu steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: python-version: 3.x - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v7 with: name: wheels-linux-${{ matrix.platform.target }} path: dist musllinux: runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: ubuntu-22.04 target: x86_64 - runner: ubuntu-22.04 target: x86 - runner: ubuntu-22.04 target: aarch64 - runner: ubuntu-22.04 target: armv7 steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: python-version: 3.x - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} manylinux: musllinux_1_2 - name: Upload wheels uses: actions/upload-artifact@v7 with: name: wheels-musllinux-${{ matrix.platform.target }} path: dist windows: runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: windows-latest target: x64 - runner: windows-latest target: x86 steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: python-version: 3.x architecture: ${{ matrix.platform.target }} - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} - name: Upload wheels uses: actions/upload-artifact@v7 with: name: wheels-windows-${{ matrix.platform.target }} path: dist macos: runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: macos-15-intel target: x86_64 - runner: macos-15 target: aarch64 steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: python-version: 3.x - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} args: --release --out dist --find-interpreter sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} - name: Upload wheels uses: actions/upload-artifact@v7 with: name: wheels-macos-${{ matrix.platform.target }} path: dist sdist: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - name: Build sdist uses: PyO3/maturin-action@v1 with: command: sdist args: --out dist - name: Upload sdist uses: actions/upload-artifact@v7 with: name: wheels-sdist path: dist tests: name: Tests runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"] steps: - uses: actions/checkout@v6 - name: Set up Python uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - uses: astral-sh/setup-uv@v7 - name: Build fastcrc run: uv run pip install . - name: Run unit tests run: uv run python tests/test_fastcrc.py release: name: Release runs-on: ubuntu-latest if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} needs: [linux, musllinux, windows, macos, sdist, tests] permissions: # Use to sign the release artifacts id-token: write # Used to upload release artifacts contents: write # Used to generate artifact attestation attestations: write steps: - uses: actions/download-artifact@v8 - name: Generate artifact attestation uses: actions/attest-build-provenance@v4 with: subject-path: "wheels-*/*" - name: Publish to PyPI if: ${{ startsWith(github.ref, 'refs/tags/') }} uses: PyO3/maturin-action@v1 with: command: upload args: --non-interactive --skip-existing wheels-*/* fastcrc-0.3.6/.gitignore000066400000000000000000000041271517655752000151560ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C/Rust extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover *.py,cover .hypothesis/ .pytest_cache/ cover/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 db.sqlite3-journal # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder .pybuilder/ target/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # pyenv # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: # .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # However, in case of collaboration, if having platform-specific dependencies or dependencies # having no cross-platform support, pipenv may install dependencies that don't work, or not # install all needed dependencies. #Pipfile.lock # PEP 582; used by e.g. github.com/David-OConnor/pyflow __pypackages__/ # Celery stuff celerybeat-schedule celerybeat.pid # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre type checker .pyre/ # pytype static type analyzer .pytype/ # Generated by Cargo # will have compiled files and executables /target/ # These are backup files generated by rustfmt **/*.rs.bk fastcrc-0.3.6/.readthedocs.yaml000066400000000000000000000014501517655752000164110ustar00rootroot00000000000000# .readthedocs.yaml # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Set the version of Python and other tools you might need build: os: ubuntu-22.04 tools: python: "3.12" rust: "1.70" jobs: pre_install: - pip install maturin - maturin build --release - pip install target/wheels/fastcrc*.whl # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py builder: html fail_on_warning: false # We recommend specifying your dependencies to enable reproducible builds: # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html python: install: - requirements: docs/requirements.txt # Build PDF & ePub formats: - epub - pdffastcrc-0.3.6/CHANGELOG.rst000066400000000000000000000031401517655752000152010ustar00rootroot00000000000000========== Change Log ========== This document records all notable changes to `fastcrc `_. 0.3.6 (May 06, 2026) -------------------- * feat: add `fastcrc.crc64.tms570_iso` for the TI Hercules TMS570 CRC-64-ISO algorithm. (`#30 `_) 0.3.5 (January 01, 2026) ------------------------ * feat: add `riscv64gc-unknown-linux-gnu` build target. (`#27 `_) 0.3.4 (October 26, 2025) ------------------------ * chore: mark module as gil-free. (`#17 `_) 0.3.3 (October 09, 2025) ------------------------ * chore: bump third-party dependencies. 0.3.1 (October 23, 2024) ------------------------ * chore: add wheels for Python 3.13, pypy 3.8, pypy 3.9 and pypy 3.10. 0.3.0 (January 2, 2024) ----------------------- * feat: add support for 8 bit CRCs. (`#5 `_) * chore: drop support for Python 3.6. (`#6 `_) 0.2.1 (September 15, 2022) --------------------- * feat: add `fastcrc.crc16.ibm_refin` and `fastcrc.crc32.reversed_reciprocal_refin`, these are two experimental functions that may be removed in the future. * chore: build wheels for more platforms. * docs: improve documentation. 0.2.0 (June 19, 2022) --------------------- * Add initial value optional parameter to all CRC functions. (`#1 `_) 0.1.1 (May 23, 2021) --------------------- * Correct the project information. 0.1.0 (May 23, 2021) --------------------- * First release. fastcrc-0.3.6/Cargo.lock000066400000000000000000000113731517655752000150740ustar00rootroot00000000000000# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 4 [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "crc" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9710d3b3739c2e349eb44fe848ad0b7c8cb1e42bd87ee49371df2f7acaf3e675" dependencies = [ "crc-catalog", ] [[package]] name = "crc-catalog" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "fastcrc" version = "0.3.6" dependencies = [ "crc", "paste", "pyo3", ] [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indoc" version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "libc" version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" [[package]] name = "memoffset" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] [[package]] name = "once_cell" version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "portable-atomic" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "proc-macro2" version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ba0117f4212101ee6544044dae45abe1083d30ce7b29c4b5cbdfa2354e07383" dependencies = [ "indoc", "libc", "memoffset", "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", "pyo3-macros", "unindent", ] [[package]] name = "pyo3-build-config" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fc6ddaf24947d12a9aa31ac65431fb1b851b8f4365426e182901eabfb87df5f" dependencies = [ "target-lexicon", ] [[package]] name = "pyo3-ffi" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "025474d3928738efb38ac36d4744a74a400c901c7596199e20e45d98eb194105" dependencies = [ "libc", "pyo3-build-config", ] [[package]] name = "pyo3-macros" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e64eb489f22fe1c95911b77c44cc41e7c19f3082fc81cce90f657cdc42ffded" dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", "syn", ] [[package]] name = "pyo3-macros-backend" version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "100246c0ecf400b475341b8455a9213344569af29a3c841d29270e53102e0fcf" dependencies = [ "heck", "proc-macro2", "pyo3-build-config", "quote", "syn", ] [[package]] name = "quote" version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "syn" version = "2.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "target-lexicon" version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c" [[package]] name = "unicode-ident" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" [[package]] name = "unindent" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" fastcrc-0.3.6/Cargo.toml000066400000000000000000000007631517655752000151200ustar00rootroot00000000000000[package] name = "fastcrc" version = "0.3.6" authors = ["overcat <4catcode@gmail.com>"] edition = "2021" description = "A hyper-fast Python module for computing CRC(8, 16, 32, 64) checksum" license = "MIT License" repository = "https://github.com/overcat/fastcrc" homepage = "https://github.com/overcat/fastcrc" readme = "README.rst" keywords = ["crc", "crc8", "crc16", "crc32", "crc64"] [lib] name = "fastcrc" crate-type = ["cdylib"] [dependencies] pyo3 = "0.26.0" crc = "3.3.0" paste = "1.0.15" fastcrc-0.3.6/LICENSE000066400000000000000000000020501517655752000141640ustar00rootroot00000000000000MIT License Copyright (c) 2021 overcat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. fastcrc-0.3.6/README.rst000066400000000000000000000026111517655752000146510ustar00rootroot00000000000000======= fastcrc ======= .. image:: https://img.shields.io/readthedocs/fastcrc.svg?style=flat&maxAge=1800 :alt: Read the Docs :target: https://fastcrc.readthedocs.io/ .. image:: https://img.shields.io/pypi/v/fastcrc.svg?style=flat&maxAge=1800 :alt: PyPI :target: https://pypi.python.org/pypi/fastcrc .. image:: https://img.shields.io/badge/python-%3E%3D3.7-blue?style=flat :alt: Python - Version :target: https://pypi.python.org/pypi/fastcrc A hyper-fast Python module for computing CRC(8, 16, 32, 64) checksum. Installation ============ .. code-block:: text pip install fastcrc Usage ===== .. code:: python from fastcrc import crc8, crc16, crc32, crc64 data = b"123456789" print(f"crc8 checksum with cdma2000 algorithm: {crc8.cdma2000(data)}") print(f"crc16 checksum with xmodem algorithm: {crc16.xmodem(data)}") print(f"crc32 checksum with aixm algorithm: {crc32.aixm(data)}") print(f"crc64 checksum with ecma_182 algorithm: {crc64.ecma_182(data)}") print(f"crc16 checksum with xmodem algorithm (with initial data): {crc16.xmodem(b'56789', crc16.xmodem(b'1234'))}") Documentation ============= fastcrc's documentation can be found at https://fastcrc.readthedocs.io License ======= fastcrc is licensed under `MIT License`_. Thanks ======= fastcrc is made possible by `crc-rs`_. .. _MIT License: ./LICENSE .. _crc-rs: https://github.com/mrhooray/crc-rsfastcrc-0.3.6/benchmarks/000077500000000000000000000000001517655752000152775ustar00rootroot00000000000000fastcrc-0.3.6/benchmarks/benchmark_result.txt000066400000000000000000000720741517655752000214020ustar00rootroot00000000000000Runtime Information OS: macOS 11.3.1 20E241 arm64 Host: MacBookAir10,1 ===================================================================== test session starts ===================================================================== platform darwin -- Python 3.9.1, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000) rootdir: [ignore] plugins: benchmark-3.4.1 collected 45 items test_benchmark.py ............................................. [100%] ---------------------------------------------- benchmark 'crc_16_arc': 1 tests ---------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_16_arc 166.0000 31,125.0000 258.3466 173.0802 250.0000 0.0000 25;24743 3.8708 83334 1 ----------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_cdma2000': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------- test_crc_16_cdma2000 196.2500 1,364.5800 201.4409 12.5406 199.1700 2.0800 1329;6510 4.9642 47905 100 ------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_cms': 1 tests ---------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ---------------------------------------------------------------------------------------------------------------------------- test_crc_16_cms 196.1667 3,774.3333 203.8097 27.6882 201.4167 1.7500 987;26658 4.9065 193536 24 ---------------------------------------------------------------------------------------------------------------------------- -------------------------------------------- benchmark 'crc_16_dds_110': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------ test_crc_16_dds_110 194.4167 24,088.5417 202.8665 64.2979 201.3750 3.4583 283;9231 4.9294 196735 24 ------------------------------------------------------------------------------------------------------------------------------ --------------------------------------------- benchmark 'crc_16_dect_r': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_16_dect_r 185.8300 1,352.9100 191.4005 14.5956 189.5800 2.0800 1052;4019 5.2246 50000 100 ----------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_dect_x': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_16_dect_x 185.8300 1,171.6600 191.9523 18.1382 189.1700 2.0800 1480;5592 5.2096 50209 100 ----------------------------------------------------------------------------------------------------------------------------- -------------------------------------------- benchmark 'crc_16_dnp': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------- test_crc_16_dnp 196.2500 997.0800 200.2734 12.0383 198.3400 1.2500 978;6259 4.9932 40269 100 ------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_en_13757': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations -------------------------------------------------------------------------------------------------------------------------------- test_crc_16_en_13757 196.1667 2,505.2083 205.1679 27.1350 201.4167 3.4583 4476;16537 4.8741 196696 24 -------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_genibus': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------- test_crc_16_genibus 194.4167 3,843.7500 204.1433 28.3506 201.3750 3.4583 2772;19107 4.8985 198374 24 ------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------- benchmark 'crc_16_gsm': 1 tests ---------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_16_gsm 196.1667 4,147.5417 205.5064 32.8501 201.4167 3.4583 5164;20316 4.8660 196696 24 ----------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_ibm_3740': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations -------------------------------------------------------------------------------------------------------------------------------- test_crc_16_ibm_3740 194.4167 5,651.0417 204.5221 31.9271 201.3750 3.4583 4137;19117 4.8894 191976 24 -------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------- benchmark 'crc_16_ibm_sdlc': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations --------------------------------------------------------------------------------------------------------------------------------- test_crc_16_ibm_sdlc 166.0000 18,792.0000 260.8980 108.9335 250.0000 0.0000 637;21313 3.8329 100001 1 --------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_iso_iec_14443_3_a': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------------------- test_crc_16_iso_iec_14443_3_a 166.0000 40,000.0000 261.4014 216.2010 250.0000 0.0000 38;11431 3.8255 56339 1 ----------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------- benchmark 'crc_16_kermit': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ---------------------------------------------------------------------------------------------------------------------------- test_crc_16_kermit 195.8300 5,019.1600 202.7438 36.7877 198.7500 3.3300 919;6493 4.9323 46243 100 ---------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_lj1200': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------ test_crc_16_lj1200 195.0909 3,740.5000 204.3170 26.1305 202.6364 3.7727 1074;11150 4.8944 157904 22 ------------------------------------------------------------------------------------------------------------------------------ --------------------------------------------- benchmark 'crc_16_maxim_dow': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations --------------------------------------------------------------------------------------------------------------------------------- test_crc_16_maxim_dow 196.1667 5,250.0000 205.2624 47.6123 201.4167 3.4583 1406;19030 4.8718 195122 24 --------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_mcrf4xx': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------- test_crc_16_mcrf4xx 194.4583 1,331.5833 202.4190 10.3783 201.3750 3.4583 5462;12976 4.9402 196735 24 ------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_modbus': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_16_modbus 196.1667 2,012.1250 202.3357 13.6027 201.3750 3.4583 2002;8169 4.9423 195122 24 ----------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_nrsc_5': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------ test_crc_16_nrsc_5 196.1667 97,901.0417 205.5541 247.0066 201.4167 5.1667 399;7949 4.8649 195122 24 ------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------- benchmark 'crc_16_opensafety_a': 1 tests ------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations -------------------------------------------------------------------------------------------------------------------------------- test_crc_16_opensafety_a 195.4200 492.0800 199.2336 5.5894 198.3400 1.2600 1667;5168 5.0192 47524 100 -------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_opensafety_b': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------------- test_crc_16_opensafety_b 194.4167 1,755.2083 202.0726 10.1175 201.3750 3.4583 2846;8274 4.9487 193574 24 ----------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------- benchmark 'crc_16_profibus': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------ test_crc_16_profibus 194.4167 6,192.7083 202.5672 23.3796 201.3750 3.4583 626;8846 4.9366 196735 24 ------------------------------------------------------------------------------------------------------------------------------ --------------------------------------------- benchmark 'crc_16_riello': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------ test_crc_16_riello 195.6522 2,905.7826 203.0066 13.6113 201.0870 1.8261 2668;26635 4.9259 195122 23 ------------------------------------------------------------------------------------------------------------------------------ --------------------------------------------- benchmark 'crc_16_spi_fujitsu': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------------- test_crc_16_spi_fujitsu 196.1667 2,105.8750 202.9069 11.2547 201.4167 1.7500 2280;23791 4.9284 193536 24 ----------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------- benchmark 'crc_16_t10_dif': 1 tests ------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations --------------------------------------------------------------------------------------------------------------------------- test_crc_16_t10_dif 195.4100 717.0800 199.2835 6.0620 198.3400 1.6700 1955;4074 5.0180 47059 100 --------------------------------------------------------------------------------------------------------------------------- -------------------------------------------- benchmark 'crc_16_teledisk': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------ test_crc_16_teledisk 195.8400 4,693.3400 204.2122 22.4418 202.9200 7.0800 225;456 4.8969 46601 100 ------------------------------------------------------------------------------------------------------------------------------ ----------------------------------------------- benchmark 'crc_16_tms37157': 1 tests ----------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------------ test_crc_16_tms37157 194.4167 574,791.6667 221.8333 1,615.3406 201.3750 5.2083 204;18158 4.5079 192013 24 ------------------------------------------------------------------------------------------------------------------------------------ ---------------------------------------------- benchmark 'crc_16_umts': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_16_umts 193.8261 3,577.9130 203.8148 20.6832 201.0870 3.6087 1763;19049 4.9064 200000 23 ----------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_16_usb': 1 tests ---------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ---------------------------------------------------------------------------------------------------------------------------- test_crc_16_usb 195.6522 1,663.0435 202.1832 9.5473 201.0870 1.8261 3884;20083 4.9460 193536 23 ---------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------- benchmark 'crc_16_xmodem': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------- test_crc_16_xmodem 166.0000 17,458.0000 259.9899 60.5777 250.0000 0.0000 1862;35386 3.8463 158958 1 ------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------- benchmark 'crc_32_aixm': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_32_aixm 190.9583 3,088.5417 199.9149 18.4566 197.9167 1.7500 1402;28205 5.0021 200000 24 ----------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_32_autosar': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------- test_crc_32_autosar 196.1667 1,967.0417 203.0787 11.1956 201.4167 1.7500 3334;26004 4.9242 195122 24 ------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_32_base91_d': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations -------------------------------------------------------------------------------------------------------------------------------- test_crc_32_base91_d 194.4583 1,859.3750 202.7007 10.1462 201.4167 1.7500 2971;23516 4.9334 193536 24 -------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_32_bzip2': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_32_bzip2 192.7083 2,649.2917 200.6396 12.7911 199.6667 1.7500 2024;22126 4.9841 195122 24 ----------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_32_cd_rom_edc': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ---------------------------------------------------------------------------------------------------------------------------------- test_crc_32_cd_rom_edc 196.1667 1,770.8333 203.0142 13.4588 201.4167 1.7500 2708;19793 4.9258 190477 24 ---------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_32_cksum': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_32_cksum 192.7083 2,286.4583 200.1064 15.9910 199.6250 1.7500 1240;19042 4.9973 195122 24 ----------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_32_iscsi': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_32_iscsi 196.1667 1,730.9167 203.0632 11.2637 201.4167 1.7500 3625;20036 4.9246 193574 24 ----------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_32_iso_hdlc': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------- test_crc_32_iso_hdlc 196.1667 7,748.2500 203.6813 26.3125 203.1250 1.7500 487;19801 4.9096 193574 24 ------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- benchmark 'crc_32_jamcrc': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------ test_crc_32_jamcrc 193.8696 2,027.1739 201.6690 15.2881 201.0870 1.7826 1518;19659 4.9586 200000 23 ------------------------------------------------------------------------------------------------------------------------------ --------------------------------------------- benchmark 'crc_32_mpeg_2': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------ test_crc_32_mpeg_2 192.7083 1,652.7500 200.2063 11.9956 199.6250 1.7500 4570;22393 4.9948 195122 24 ------------------------------------------------------------------------------------------------------------------------------ ---------------------------------------------- benchmark 'crc_32_xfer': 1 tests --------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_32_xfer 192.7083 1,600.7083 199.6054 12.3965 197.9167 1.7500 2279;18659 5.0099 195122 24 ----------------------------------------------------------------------------------------------------------------------------- -------------------------------------------- benchmark 'crc_64_ecma_182': 1 tests -------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ------------------------------------------------------------------------------------------------------------------------------ test_crc_64_ecma_182 194.4583 1,675.3333 202.0231 9.1745 201.3750 3.4583 3381;6035 4.9499 193536 24 ------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------- benchmark 'crc_64_go_iso': 1 tests ------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations -------------------------------------------------------------------------------------------------------------------------- test_crc_64_go_iso 196.6600 692.9200 200.5794 6.9161 199.5800 2.0800 2058;4931 4.9856 47244 100 -------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------- benchmark 'crc_64_we': 1 tests ---------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_64_we 194.4167 3,123.2917 203.6679 14.4475 201.3750 5.1667 6953;13257 4.9100 195122 24 ----------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------- benchmark 'crc_64_xz': 1 tests ---------------------------------------------- Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Mops/s) Rounds Iterations ----------------------------------------------------------------------------------------------------------------------------- test_crc_64_xz 196.1667 1,498.2500 203.2122 10.5812 203.1250 1.7500 2754;21916 4.9210 193536 24 ----------------------------------------------------------------------------------------------------------------------------- Legend: Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile. OPS: Operations Per Second, computed as 1 / Mean ===================================================================== 45 passed in 55.28s ====================================================================== fastcrc-0.3.6/benchmarks/requirements.txt000066400000000000000000000000271517655752000205620ustar00rootroot00000000000000pytest pytest-benchmarkfastcrc-0.3.6/benchmarks/test_benchmark.py000066400000000000000000000130261517655752000206440ustar00rootroot00000000000000import pytest from fastcrc import crc16, crc32, crc64 test_data = b"123456789" @pytest.mark.benchmark(group="crc_16_arc") def test_crc_16_arc(benchmark): benchmark(crc16.arc, test_data) @pytest.mark.benchmark(group="crc_16_cdma2000") def test_crc_16_cdma2000(benchmark): benchmark(crc16.cdma2000, test_data) @pytest.mark.benchmark(group="crc_16_cms") def test_crc_16_cms(benchmark): benchmark(crc16.cms, test_data) @pytest.mark.benchmark(group="crc_16_dds_110") def test_crc_16_dds_110(benchmark): benchmark(crc16.dds_110, test_data) @pytest.mark.benchmark(group="crc_16_dect_r") def test_crc_16_dect_r(benchmark): benchmark(crc16.dect_r, test_data) @pytest.mark.benchmark(group="crc_16_dect_x") def test_crc_16_dect_x(benchmark): benchmark(crc16.dect_x, test_data) @pytest.mark.benchmark(group="crc_16_dnp") def test_crc_16_dnp(benchmark): benchmark(crc16.dnp, test_data) @pytest.mark.benchmark(group="crc_16_en_13757") def test_crc_16_en_13757(benchmark): benchmark(crc16.en_13757, test_data) @pytest.mark.benchmark(group="crc_16_genibus") def test_crc_16_genibus(benchmark): benchmark(crc16.genibus, test_data) @pytest.mark.benchmark(group="crc_16_gsm") def test_crc_16_gsm(benchmark): benchmark(crc16.gsm, test_data) @pytest.mark.benchmark(group="crc_16_ibm_3740") def test_crc_16_ibm_3740(benchmark): benchmark(crc16.ibm_3740, test_data) @pytest.mark.benchmark(group="crc_16_ibm_sdlc") def test_crc_16_ibm_sdlc(benchmark): benchmark(crc16.ibm_sdlc, test_data) @pytest.mark.benchmark(group="crc_16_iso_iec_14443_3_a") def test_crc_16_iso_iec_14443_3_a(benchmark): benchmark(crc16.iso_iec_14443_3_a, test_data) @pytest.mark.benchmark(group="crc_16_kermit") def test_crc_16_kermit(benchmark): benchmark(crc16.kermit, test_data) @pytest.mark.benchmark(group="crc_16_lj1200") def test_crc_16_lj1200(benchmark): benchmark(crc16.lj1200, test_data) @pytest.mark.benchmark(group="crc_16_maxim_dow") def test_crc_16_maxim_dow(benchmark): benchmark(crc16.maxim_dow, test_data) @pytest.mark.benchmark(group="crc_16_mcrf4xx") def test_crc_16_mcrf4xx(benchmark): benchmark(crc16.mcrf4xx, test_data) @pytest.mark.benchmark(group="crc_16_modbus") def test_crc_16_modbus(benchmark): benchmark(crc16.modbus, test_data) @pytest.mark.benchmark(group="crc_16_nrsc_5") def test_crc_16_nrsc_5(benchmark): benchmark(crc16.nrsc_5, test_data) @pytest.mark.benchmark(group="crc_16_opensafety_a") def test_crc_16_opensafety_a(benchmark): benchmark(crc16.opensafety_a, test_data) @pytest.mark.benchmark(group="crc_16_opensafety_b") def test_crc_16_opensafety_b(benchmark): benchmark(crc16.opensafety_b, test_data) @pytest.mark.benchmark(group="crc_16_profibus") def test_crc_16_profibus(benchmark): benchmark(crc16.profibus, test_data) @pytest.mark.benchmark(group="crc_16_riello") def test_crc_16_riello(benchmark): benchmark(crc16.riello, test_data) @pytest.mark.benchmark(group="crc_16_spi_fujitsu") def test_crc_16_spi_fujitsu(benchmark): benchmark(crc16.spi_fujitsu, test_data) @pytest.mark.benchmark(group="crc_16_t10_dif") def test_crc_16_t10_dif(benchmark): benchmark(crc16.t10_dif, test_data) @pytest.mark.benchmark(group="crc_16_teledisk") def test_crc_16_teledisk(benchmark): benchmark(crc16.teledisk, test_data) @pytest.mark.benchmark(group="crc_16_tms37157") def test_crc_16_tms37157(benchmark): benchmark(crc16.tms37157, test_data) @pytest.mark.benchmark(group="crc_16_umts") def test_crc_16_umts(benchmark): benchmark(crc16.umts, test_data) @pytest.mark.benchmark(group="crc_16_usb") def test_crc_16_usb(benchmark): benchmark(crc16.usb, test_data) @pytest.mark.benchmark(group="crc_16_xmodem") def test_crc_16_xmodem(benchmark): benchmark(crc16.xmodem, test_data) @pytest.mark.benchmark(group="crc_32_aixm") def test_crc_32_aixm(benchmark): benchmark(crc32.aixm, test_data) @pytest.mark.benchmark(group="crc_32_autosar") def test_crc_32_autosar(benchmark): benchmark(crc32.autosar, test_data) @pytest.mark.benchmark(group="crc_32_base91_d") def test_crc_32_base91_d(benchmark): benchmark(crc32.base91_d, test_data) @pytest.mark.benchmark(group="crc_32_bzip2") def test_crc_32_bzip2(benchmark): benchmark(crc32.bzip2, test_data) @pytest.mark.benchmark(group="crc_32_cd_rom_edc") def test_crc_32_cd_rom_edc(benchmark): benchmark(crc32.cd_rom_edc, test_data) @pytest.mark.benchmark(group="crc_32_cksum") def test_crc_32_cksum(benchmark): benchmark(crc32.cksum, test_data) @pytest.mark.benchmark(group="crc_32_iscsi") def test_crc_32_iscsi(benchmark): benchmark(crc32.iscsi, test_data) @pytest.mark.benchmark(group="crc_32_iso_hdlc") def test_crc_32_iso_hdlc(benchmark): benchmark(crc32.iso_hdlc, test_data) @pytest.mark.benchmark(group="crc_32_jamcrc") def test_crc_32_jamcrc(benchmark): benchmark(crc32.jamcrc, test_data) @pytest.mark.benchmark(group="crc_32_mpeg_2") def test_crc_32_mpeg_2(benchmark): benchmark(crc32.mpeg_2, test_data) @pytest.mark.benchmark(group="crc_32_xfer") def test_crc_32_xfer(benchmark): benchmark(crc32.xfer, test_data) @pytest.mark.benchmark(group="crc_64_ecma_182") def test_crc_64_ecma_182(benchmark): benchmark(crc64.ecma_182, test_data) @pytest.mark.benchmark(group="crc_64_go_iso") def test_crc_64_go_iso(benchmark): benchmark(crc64.go_iso, test_data) @pytest.mark.benchmark(group="crc_64_we") def test_crc_64_we(benchmark): benchmark(crc64.we, test_data) @pytest.mark.benchmark(group="crc_64_xz") def test_crc_64_xz(benchmark): benchmark(crc64.xz, test_data) fastcrc-0.3.6/docs/000077500000000000000000000000001517655752000141125ustar00rootroot00000000000000fastcrc-0.3.6/docs/Makefile000066400000000000000000000011721517655752000155530ustar00rootroot00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) fastcrc-0.3.6/docs/conf.py000066400000000000000000000040621517655752000154130ustar00rootroot00000000000000# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # import os # import sys # sys.path.insert(0, os.path.abspath('.')) import fastcrc # -- Project information ----------------------------------------------------- project = "fastcrc" copyright = "2021, overcat" author = "overcat" # The full version, including alpha/beta/rc tags release = fastcrc.__version__ # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ "sphinx.ext.autodoc", "sphinx.ext.viewcode", ] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = "alabaster" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] html_theme_options = { # Disable showing the sidebar. Defaults to 'false' "nosidebar": True, } fastcrc-0.3.6/docs/index.rst000066400000000000000000000005551517655752000157600ustar00rootroot00000000000000.. include:: ../README.rst API Reference ============= CRC 8 ----- .. automodule:: fastcrc.crc8 :members: :undoc-members: CRC 16 ------ .. automodule:: fastcrc.crc16 :members: :undoc-members: CRC 32 ------ .. automodule:: fastcrc.crc32 :members: :undoc-members: CRC 64 ------ .. automodule:: fastcrc.crc64 :members: :undoc-members: fastcrc-0.3.6/docs/make.bat000066400000000000000000000013701517655752000155200ustar00rootroot00000000000000@ECHO OFF pushd %~dp0 REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set SOURCEDIR=. set BUILDDIR=_build if "%1" == "" goto help %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% goto end :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% :end popd fastcrc-0.3.6/docs/requirements.txt000066400000000000000000000000061517655752000173720ustar00rootroot00000000000000sphinxfastcrc-0.3.6/fastcrc/000077500000000000000000000000001517655752000146075ustar00rootroot00000000000000fastcrc-0.3.6/fastcrc/__info__.py000066400000000000000000000004551517655752000167140ustar00rootroot00000000000000__title__ = "fastcrc" __description__ = "A hyper-fast Python module for computing CRC(16, 32, 64) checksum" __url__ = "https://github.com/overcat/fastcrc" __issues__ = f"{__url__}/issues" __version__ = "0.3.6" __author__ = "overcat" __author_email__ = "4catcode@gmail.com" __license__ = "MIT License" fastcrc-0.3.6/fastcrc/__init__.py000066400000000000000000000003131517655752000167150ustar00rootroot00000000000000from . import crc8, crc16, crc32, crc64 from .__info__ import ( __author__, __author_email__, __description__, __issues__, __license__, __title__, __url__, __version__, ) fastcrc-0.3.6/fastcrc/crc16.py000066400000000000000000000470061517655752000161060ustar00rootroot00000000000000""" Compute a CRC-16 checksum of data. """ from typing import Optional from .fastcrc import crc_16_arc as _crc_16_arc from .fastcrc import crc_16_cdma2000 as _crc_16_cdma2000 from .fastcrc import crc_16_cms as _crc_16_cms from .fastcrc import crc_16_dds_110 as _crc_16_dds_110 from .fastcrc import crc_16_dect_r as _crc_16_dect_r from .fastcrc import crc_16_dect_x as _crc_16_dect_x from .fastcrc import crc_16_dnp as _crc_16_dnp from .fastcrc import crc_16_en_13757 as _crc_16_en_13757 from .fastcrc import crc_16_genibus as _crc_16_genibus from .fastcrc import crc_16_gsm as _crc_16_gsm from .fastcrc import crc_16_ibm_3740 as _crc_16_ibm_3740 from .fastcrc import crc_16_ibm_sdlc as _crc_16_ibm_sdlc from .fastcrc import crc_16_iso_iec_14443_3_a as _crc_16_iso_iec_14443_3_a from .fastcrc import crc_16_kermit as _crc_16_kermit from .fastcrc import crc_16_lj1200 as _crc_16_lj1200 from .fastcrc import crc_16_maxim_dow as _crc_16_maxim_dow from .fastcrc import crc_16_mcrf4xx as _crc_16_mcrf4xx from .fastcrc import crc_16_modbus as _crc_16_modbus from .fastcrc import crc_16_nrsc_5 as _crc_16_nrsc_5 from .fastcrc import crc_16_opensafety_a as _crc_16_opensafety_a from .fastcrc import crc_16_opensafety_b as _crc_16_opensafety_b from .fastcrc import crc_16_profibus as _crc_16_profibus from .fastcrc import crc_16_riello as _crc_16_riello from .fastcrc import crc_16_spi_fujitsu as _crc_16_spi_fujitsu from .fastcrc import crc_16_t10_dif as _crc_16_t10_dif from .fastcrc import crc_16_teledisk as _crc_16_teledisk from .fastcrc import crc_16_tms37157 as _crc_16_tms37157 from .fastcrc import crc_16_umts as _crc_16_umts from .fastcrc import crc_16_usb as _crc_16_usb from .fastcrc import crc_16_xmodem as _crc_16_xmodem from .fastcrc import crc_16_ibm_refin as _crc_16_ibm_refin __always_supported = ( "arc", "cdma2000", "cms", "dds_110", "dect_r", "dect_x", "dnp", "en_13757", "genibus", "gsm", "ibm_3740", "ibm_sdlc", "iso_iec_14443_3_a", "kermit", "lj1200", "maxim_dow", "mcrf4xx", "modbus", "nrsc_5", "opensafety_a", "opensafety_b", "profibus", "riello", "spi_fujitsu", "t10_dif", "teledisk", "tms37157", "umts", "usb", "xmodem", ) algorithms_guaranteed = set(__always_supported) algorithms_available = set(__always_supported) def arc(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `arc` algorithm. Algorithm parameters: - ploy: 0x8005 - init: 0x0000 - xorout: 0x0000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_arc(data, initial) def cdma2000(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `cdma2000` algorithm. Algorithm parameters: - ploy: 0xc867 - init: 0xffff - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_cdma2000(data, initial) def cms(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `cms` algorithm. Algorithm parameters: - ploy: 0x8005 - init: 0xffff - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_cms(data, initial) def dds_110(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `dds 110` algorithm. Algorithm parameters: - ploy: 0x8005 - init: 0x800d - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_dds_110(data, initial) def dect_r(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `dect r` algorithm. Algorithm parameters: - ploy: 0x0589 - init: 0x0000 - xorout: 0x0001 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_dect_r(data, initial) def dect_x(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `dect x` algorithm. Algorithm parameters: - ploy: 0x0589 - init: 0x0000 - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_dect_x(data, initial) def dnp(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `dnp` algorithm. Algorithm parameters: - ploy: 0x3d65 - init: 0x0000 - xorout: 0xffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_dnp(data, initial) def en_13757(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `en 13757` algorithm. Algorithm parameters: - ploy: 0x3d65 - init: 0x0000 - xorout: 0xffff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_en_13757(data, initial) def genibus(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `genibus` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0xffff - xorout: 0xffff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_genibus(data, initial) def gsm(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `gsm` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0x0000 - xorout: 0xffff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_gsm(data, initial) def ibm_3740(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `ibm 3740` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0xffff - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_ibm_3740(data, initial) def ibm_sdlc(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `ibm sdlc` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0xffff - xorout: 0xffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_ibm_sdlc(data, initial) def iso_iec_14443_3_a(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `iso iec 14443 3 a` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0xc6c6 - xorout: 0x0000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_iso_iec_14443_3_a(data, initial) def kermit(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `kermit` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0x0000 - xorout: 0x0000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_kermit(data, initial) def lj1200(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `lj1200` algorithm. Algorithm parameters: - ploy: 0x6f63 - init: 0x0000 - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_lj1200(data, initial) def maxim_dow(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `maxim dow` algorithm. Algorithm parameters: - ploy: 0x8005 - init: 0x0000 - xorout: 0xffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_maxim_dow(data, initial) def mcrf4xx(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `mcrf4xx` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0xffff - xorout: 0x0000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_mcrf4xx(data, initial) def modbus(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `modbus` algorithm. Algorithm parameters: - ploy: 0x8005 - init: 0xffff - xorout: 0x0000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_modbus(data, initial) def nrsc_5(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `nrsc 5` algorithm. Algorithm parameters: - ploy: 0x080b - init: 0xffff - xorout: 0x0000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_nrsc_5(data, initial) def opensafety_a(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `opensafety a` algorithm. Algorithm parameters: - ploy: 0x5935 - init: 0x0000 - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_opensafety_a(data, initial) def opensafety_b(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `opensafety b` algorithm. Algorithm parameters: - ploy: 0x755b - init: 0x0000 - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_opensafety_b(data, initial) def profibus(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `profibus` algorithm. Algorithm parameters: - ploy: 0x1dcf - init: 0xffff - xorout: 0xffff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_profibus(data, initial) def riello(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `riello` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0xb2aa - xorout: 0x0000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_riello(data, initial) def spi_fujitsu(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `spi fujitsu` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0x1d0f - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_spi_fujitsu(data, initial) def t10_dif(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `t10 dif` algorithm. Algorithm parameters: - ploy: 0x8bb7 - init: 0x0000 - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_t10_dif(data, initial) def teledisk(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `teledisk` algorithm. Algorithm parameters: - ploy: 0xa097 - init: 0x0000 - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_teledisk(data, initial) def tms37157(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `tms37157` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0x89ec - xorout: 0x0000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_tms37157(data, initial) def umts(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `umts` algorithm. Algorithm parameters: - ploy: 0x8005 - init: 0x0000 - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_umts(data, initial) def usb(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `usb` algorithm. Algorithm parameters: - ploy: 0x8005 - init: 0xffff - xorout: 0xffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_usb(data, initial) def xmodem(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `xmodem` algorithm. Algorithm parameters: - ploy: 0x1021 - init: 0x0000 - xorout: 0x0000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_xmodem(data, initial) def ibm_refin(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-16 checksum of data with the `ibm refin` algorithm. **This method may be removed in the future.** Algorithm parameters: - ploy: 0x8005 - init: 0x0000 - xorout: 0x0000 - refin: True - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_16_ibm_refin(data, initial) fastcrc-0.3.6/fastcrc/crc32.py000066400000000000000000000175741517655752000161130ustar00rootroot00000000000000""" Compute a CRC-32 checksum of data. """ from typing import Optional from .fastcrc import crc_32_aixm as _crc_32_aixm from .fastcrc import crc_32_autosar as _crc_32_autosar from .fastcrc import crc_32_base91_d as _crc_32_base91_d from .fastcrc import crc_32_bzip2 as _crc_32_bzip2 from .fastcrc import crc_32_cd_rom_edc as _crc_32_cd_rom_edc from .fastcrc import crc_32_cksum as _crc_32_cksum from .fastcrc import crc_32_iscsi as _crc_32_iscsi from .fastcrc import crc_32_iso_hdlc as _crc_32_iso_hdlc from .fastcrc import crc_32_jamcrc as _crc_32_jamcrc from .fastcrc import crc_32_mpeg_2 as _crc_32_mpeg_2 from .fastcrc import crc_32_xfer as _crc_32_xfer from .fastcrc import ( crc_32_k_reversed_reciprocal_refin as _crc_32_k_reversed_reciprocal_refin, ) __always_supported = ( "aixm", "autosar", "base91_d", "bzip2", "cd_rom_edc", "cksum", "iscsi", "iso_hdlc", "jamcrc", "mpeg_2", "xfer", ) algorithms_guaranteed = set(__always_supported) algorithms_available = set(__always_supported) def aixm(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `aixm` algorithm. Algorithm parameters: - ploy: 0x814141ab - init: 0x00000000 - xorout: 0x00000000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_aixm(data, initial) def autosar(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `autosar` algorithm. Algorithm parameters: - ploy: 0xf4acfb13 - init: 0xffffffff - xorout: 0xffffffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_autosar(data, initial) def base91_d(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `base91 d` algorithm. Algorithm parameters: - ploy: 0xa833982b - init: 0xffffffff - xorout: 0xffffffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_base91_d(data, initial) def bzip2(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `bzip2` algorithm. Algorithm parameters: - ploy: 0x04c11db7 - init: 0xffffffff - xorout: 0xffffffff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_bzip2(data, initial) def cd_rom_edc(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `cd rom edc` algorithm. Algorithm parameters: - ploy: 0x8001801b - init: 0x00000000 - xorout: 0x00000000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_cd_rom_edc(data, initial) def cksum(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `cksum` algorithm. Algorithm parameters: - ploy: 0x04c11db7 - init: 0x00000000 - xorout: 0xffffffff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_cksum(data, initial) def iscsi(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `iscsi` algorithm. Algorithm parameters: - ploy: 0x1edc6f41 - init: 0xffffffff - xorout: 0xffffffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_iscsi(data, initial) def iso_hdlc(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `iso hdlc` algorithm. Algorithm parameters: - ploy: 0x04c11db7 - init: 0xffffffff - xorout: 0xffffffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_iso_hdlc(data, initial) def jamcrc(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `jamcrc` algorithm. Algorithm parameters: - ploy: 0x04c11db7 - init: 0xffffffff - xorout: 0x00000000 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_jamcrc(data, initial) def mpeg_2(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `mpeg 2` algorithm. Algorithm parameters: - ploy: 0x04c11db7 - init: 0xffffffff - xorout: 0x00000000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_mpeg_2(data, initial) def xfer(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `xfer` algorithm. Algorithm parameters: - ploy: 0x000000af - init: 0x00000000 - xorout: 0x00000000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_xfer(data, initial) def k_reversed_reciprocal_refin(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-32 checksum of data with the `k reversed reciprocal refin` algorithm. **This method may be removed in the future.** Algorithm parameters: - ploy: 0xba0dc66b - init: 0x00000000 - xorout: 0x00000000 - refin: True - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_32_k_reversed_reciprocal_refin(data, initial) fastcrc-0.3.6/fastcrc/crc64.py000066400000000000000000000066421517655752000161120ustar00rootroot00000000000000""" Compute a CRC-64 checksum of data. """ from typing import Optional from .fastcrc import crc_64_ecma_182 as _crc_64_ecma_182 from .fastcrc import crc_64_go_iso as _crc_64_go_iso from .fastcrc import crc_64_we as _crc_64_we from .fastcrc import crc_64_xz as _crc_64_xz from .fastcrc import crc_64_tms570_iso as _crc_64_tms570_iso __always_supported = ("ecma_182", "go_iso", "we", "xz", "tms570_iso") algorithms_guaranteed = set(__always_supported) algorithms_available = set(__always_supported) def ecma_182(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-64 checksum of data with the `ecma 182` algorithm. Algorithm parameters: - ploy: 0x42f0e1eba9ea3693 - init: 0x0000000000000000 - xorout: 0x0000000000000000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_64_ecma_182(data, initial) def go_iso(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-64 checksum of data with the `go iso` algorithm. Algorithm parameters: - ploy: 0x000000000000001b - init: 0xffffffffffffffff - xorout: 0xffffffffffffffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_64_go_iso(data, initial) def we(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-64 checksum of data with the `we` algorithm. Algorithm parameters: - ploy: 0x42f0e1eba9ea3693 - init: 0xffffffffffffffff - xorout: 0xffffffffffffffff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_64_we(data, initial) def xz(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-64 checksum of data with the `xz` algorithm. Algorithm parameters: - ploy: 0x42f0e1eba9ea3693 - init: 0xffffffffffffffff - xorout: 0xffffffffffffffff - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_64_xz(data, initial) def tms570_iso(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-64 checksum of data with the `tms570_iso` algorithm. Algorithm parameters: - poly: 0x000000000000001b - init: 0x0000000000000000 - xorout: 0x0000000000000000 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_64_tms570_iso(data, initial) fastcrc-0.3.6/fastcrc/crc8.py000066400000000000000000000274311517655752000160270ustar00rootroot00000000000000""" Compute a CRC-16 checksum of data. """ from typing import Optional from .fastcrc import crc_8_autosar as _crc_8_autosar from .fastcrc import crc_8_bluetooth as _crc_8_bluetooth from .fastcrc import crc_8_cdma2000 as _crc_8_cdma2000 from .fastcrc import crc_8_darc as _crc_8_darc from .fastcrc import crc_8_dvb_s2 as _crc_8_dvb_s2 from .fastcrc import crc_8_gsm_a as _crc_8_gsm_a from .fastcrc import crc_8_gsm_b as _crc_8_gsm_b from .fastcrc import crc_8_i_432_1 as _crc_8_i_432_1 from .fastcrc import crc_8_i_code as _crc_8_i_code from .fastcrc import crc_8_lte as _crc_8_lte from .fastcrc import crc_8_maxim_dow as _crc_8_maxim_dow from .fastcrc import crc_8_mifare_mad as _crc_8_mifare_mad from .fastcrc import crc_8_nrsc_5 as _crc_8_nrsc_5 from .fastcrc import crc_8_opensafety as _crc_8_opensafety from .fastcrc import crc_8_rohc as _crc_8_rohc from .fastcrc import crc_8_sae_j1850 as _crc_8_sae_j1850 from .fastcrc import crc_8_smbus as _crc_8_smbus from .fastcrc import crc_8_tech_3250 as _crc_8_tech_3250 from .fastcrc import crc_8_wcdma as _crc_8_wcdma __always_supported = ( "autosar", "bluetooth", "cdma2000", "darc", "dvb_s2", "gsm_a", "gsm_b", "i_432_1", "i_code", "lte", "maxim_dow", "mifare_mad", "nrsc_5", "opensafety", "rohc", "sae_j1850", "smbus", "tech_3250", "wcdma", ) algorithms_guaranteed = set(__always_supported) algorithms_available = set(__always_supported) def autosar(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `autosar` algorithm. Algorithm parameters: - poly: 0x2f - init: 0xff - xorout: 0xff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_autosar(data, initial) def bluetooth(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `bluetooth` algorithm. Algorithm parameters: - poly: 0xa7 - init: 0x00 - xorout: 0x00 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_bluetooth(data, initial) def cdma2000(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `cdma2000` algorithm. Algorithm parameters: - poly: 0x9b - init: 0xff - xorout: 0x00 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_cdma2000(data, initial) def darc(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `darc` algorithm. Algorithm parameters: - poly: 0x39 - init: 0x00 - xorout: 0x00 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_darc(data, initial) def dvb_s2(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `dvb_s2` algorithm. Algorithm parameters: - poly: 0xd5 - init: 0x00 - xorout: 0x00 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_dvb_s2(data, initial) def gsm_a(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `gsm_a` algorithm. Algorithm parameters: - poly: 0x1d - init: 0x00 - xorout: 0x00 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_gsm_a(data, initial) def gsm_b(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `gsm_b` algorithm. Algorithm parameters: - poly: 0x49 - init: 0x00 - xorout: 0xff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_gsm_b(data, initial) def i_432_1(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `i_432_1` algorithm. Algorithm parameters: - poly: 0x07 - init: 0x00 - xorout: 0x55 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_i_432_1(data, initial) def i_code(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `i_code` algorithm. Algorithm parameters: - poly: 0x1d - init: 0xfd - xorout: 0x00 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_i_code(data, initial) def lte(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `lte` algorithm. Algorithm parameters: - poly: 0x9b - init: 0x00 - xorout: 0x00 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_lte(data, initial) def maxim_dow(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `maxim_dow` algorithm. Algorithm parameters: - poly: 0x31 - init: 0x00 - xorout: 0x00 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_maxim_dow(data, initial) def mifare_mad(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `mifare_mad` algorithm. Algorithm parameters: - poly: 0x1d - init: 0xc7 - xorout: 0x00 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_mifare_mad(data, initial) def nrsc_5(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `nrsc_5` algorithm. Algorithm parameters: - poly: 0x31 - init: 0xff - xorout: 0x00 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_nrsc_5(data, initial) def opensafety(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `opensafety` algorithm. Algorithm parameters: - poly: 0x2f - init: 0x00 - xorout: 0x00 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_opensafety(data, initial) def rohc(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `rohc` algorithm. Algorithm parameters: - poly: 0x07 - init: 0xff - xorout: 0x00 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_rohc(data, initial) def sae_j1850(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `sae_j1850` algorithm. Algorithm parameters: - poly: 0x1d - init: 0xff - xorout: 0xff - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_sae_j1850(data, initial) def smbus(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `smbus` algorithm. Algorithm parameters: - poly: 0x07 - init: 0x00 - xorout: 0x00 - refin: False - refout: False :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_smbus(data, initial) def tech_3250(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `tech_3250` algorithm. Algorithm parameters: - poly: 0x1d - init: 0xff - xorout: 0x00 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_tech_3250(data, initial) def wcdma(data: bytes, initial: Optional[int] = None) -> int: """ Compute a CRC-8 checksum of data with the `wcdma` algorithm. Algorithm parameters: - poly: 0x9b - init: 0x00 - xorout: 0x00 - refin: True - refout: True :param bytes data: The data to be computed :param Optional[int] initial: The optional starting value of the checksum :return: The checksum :rtype: int :raises TypeError: if the data is not a bytes-like object """ return _crc_8_wcdma(data, initial)fastcrc-0.3.6/fastcrc/py.typed000066400000000000000000000000001517655752000162740ustar00rootroot00000000000000fastcrc-0.3.6/pyproject.toml000066400000000000000000000022351517655752000161000ustar00rootroot00000000000000[project] name = "fastcrc" version = "0.3.6" requires-python = ">=3.7" readme = "README.rst" description = "A hyper-fast Python module for computing CRC(8, 16, 32, 64) checksum" authors = [{ name = "overcat", email = "4catcode@gmail.com" }] classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Rust", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", "Typing :: Typed", ] keywords = ["crc", "crc8", "crc16", "crc32", "crc64"] [project.urls] homepage = "https://github.com/overcat/fastcrc" repository = "https://github.com/overcat/fastcrc" documentation = "https://fastcrc.readthedocs.io" [build-system] requires = ["maturin>=1.5,<2.0"] build-backend = "maturin" [tool.maturin] features = ["pyo3/extension-module"] exclude = [".github/**/*", "benchmarks/**/*", "tests/**/*", "docs/**/*"] fastcrc-0.3.6/src/000077500000000000000000000000001517655752000137515ustar00rootroot00000000000000fastcrc-0.3.6/src/lib.rs000066400000000000000000000242161517655752000150720ustar00rootroot00000000000000use crc::{ Algorithm, Crc, CRC_16_ARC, CRC_16_CDMA2000, CRC_16_CMS, CRC_16_DDS_110, CRC_16_DECT_R, CRC_16_DECT_X, CRC_16_DNP, CRC_16_EN_13757, CRC_16_GENIBUS, CRC_16_GSM, CRC_16_IBM_3740, CRC_16_IBM_SDLC, CRC_16_ISO_IEC_14443_3_A, CRC_16_KERMIT, CRC_16_LJ1200, CRC_16_MAXIM_DOW, CRC_16_MCRF4XX, CRC_16_MODBUS, CRC_16_NRSC_5, CRC_16_OPENSAFETY_A, CRC_16_OPENSAFETY_B, CRC_16_PROFIBUS, CRC_16_RIELLO, CRC_16_SPI_FUJITSU, CRC_16_T10_DIF, CRC_16_TELEDISK, CRC_16_TMS37157, CRC_16_UMTS, CRC_16_USB, CRC_16_XMODEM, CRC_32_AIXM, CRC_32_AUTOSAR, CRC_32_BASE91_D, CRC_32_BZIP2, CRC_32_CD_ROM_EDC, CRC_32_CKSUM, CRC_32_ISCSI, CRC_32_ISO_HDLC, CRC_32_JAMCRC, CRC_32_MPEG_2, CRC_32_XFER, CRC_64_ECMA_182, CRC_64_GO_ISO, CRC_64_WE, CRC_64_XZ, CRC_8_AUTOSAR, CRC_8_BLUETOOTH, CRC_8_CDMA2000, CRC_8_DARC, CRC_8_DVB_S2, CRC_8_GSM_A, CRC_8_GSM_B, CRC_8_I_432_1, CRC_8_I_CODE, CRC_8_LTE, CRC_8_MAXIM_DOW, CRC_8_MIFARE_MAD, CRC_8_NRSC_5, CRC_8_OPENSAFETY, CRC_8_ROHC, CRC_8_SAE_J1850, CRC_8_SMBUS, CRC_8_TECH_3250, CRC_8_WCDMA, }; use pyo3::prelude::*; use pyo3::wrap_pyfunction; extern crate paste; // Macro to define a CRC function macro_rules! define_crc_fn { ($name:ident, $word_type:ty, $crc_type:ty) => { ::paste::paste! { #[pyfunction] #[pyo3(signature = (data, initial=None))] fn $name(data: &[u8], initial: Option<$word_type>) -> PyResult<$word_type> { const CRC: Crc<$word_type> = Crc::<$word_type>::new(&$crc_type); let mut digest = match initial { None => CRC.digest(), Some(mut value) => { // TODO: This might be a bug in crc-rs, let's fix it later. value ^= $crc_type.xorout; if $crc_type.refout { value = value.reverse_bits() } CRC.digest_with_initial(value) } }; digest.update(&data); Ok(digest.finalize()) } } }; } const CRC_16_IBM_REFIN: Algorithm = Algorithm { width: 16, poly: 0x8005, init: 0x0000, refin: true, refout: false, xorout: 0x0000, check: 0xbcdd, residue: 0x0000, }; const CRC_32_K_REVERSED_RECIPROCAL_REFIN: Algorithm = Algorithm { width: 32, poly: 0xba0dc66b, init: 0x00000000, refin: true, refout: false, xorout: 0x00000000, check: 0x949d7183, residue: 0x00000000, }; const CRC_64_TMS570_ISO: Algorithm = Algorithm { width: 64, poly: 0x000000000000001b, init: 0x0000000000000000, refin: false, refout: false, xorout: 0x0000000000000000, check: 0xe4ffbea588933790, residue: 0x0000000000000000, }; define_crc_fn!(crc_8_autosar, u8, CRC_8_AUTOSAR); define_crc_fn!(crc_8_bluetooth, u8, CRC_8_BLUETOOTH); define_crc_fn!(crc_8_cdma2000, u8, CRC_8_CDMA2000); define_crc_fn!(crc_8_darc, u8, CRC_8_DARC); define_crc_fn!(crc_8_dvb_s2, u8, CRC_8_DVB_S2); define_crc_fn!(crc_8_gsm_a, u8, CRC_8_GSM_A); define_crc_fn!(crc_8_gsm_b, u8, CRC_8_GSM_B); define_crc_fn!(crc_8_i_432_1, u8, CRC_8_I_432_1); define_crc_fn!(crc_8_i_code, u8, CRC_8_I_CODE); define_crc_fn!(crc_8_lte, u8, CRC_8_LTE); define_crc_fn!(crc_8_maxim_dow, u8, CRC_8_MAXIM_DOW); define_crc_fn!(crc_8_mifare_mad, u8, CRC_8_MIFARE_MAD); define_crc_fn!(crc_8_nrsc_5, u8, CRC_8_NRSC_5); define_crc_fn!(crc_8_opensafety, u8, CRC_8_OPENSAFETY); define_crc_fn!(crc_8_rohc, u8, CRC_8_ROHC); define_crc_fn!(crc_8_sae_j1850, u8, CRC_8_SAE_J1850); define_crc_fn!(crc_8_smbus, u8, CRC_8_SMBUS); define_crc_fn!(crc_8_tech_3250, u8, CRC_8_TECH_3250); define_crc_fn!(crc_8_wcdma, u8, CRC_8_WCDMA); define_crc_fn!(crc_16_arc, u16, CRC_16_ARC); define_crc_fn!(crc_16_cdma2000, u16, CRC_16_CDMA2000); define_crc_fn!(crc_16_cms, u16, CRC_16_CMS); define_crc_fn!(crc_16_dds_110, u16, CRC_16_DDS_110); define_crc_fn!(crc_16_dect_r, u16, CRC_16_DECT_R); define_crc_fn!(crc_16_dect_x, u16, CRC_16_DECT_X); define_crc_fn!(crc_16_dnp, u16, CRC_16_DNP); define_crc_fn!(crc_16_en_13757, u16, CRC_16_EN_13757); define_crc_fn!(crc_16_genibus, u16, CRC_16_GENIBUS); define_crc_fn!(crc_16_gsm, u16, CRC_16_GSM); define_crc_fn!(crc_16_ibm_3740, u16, CRC_16_IBM_3740); define_crc_fn!(crc_16_ibm_sdlc, u16, CRC_16_IBM_SDLC); define_crc_fn!(crc_16_iso_iec_14443_3_a, u16, CRC_16_ISO_IEC_14443_3_A); define_crc_fn!(crc_16_kermit, u16, CRC_16_KERMIT); define_crc_fn!(crc_16_lj1200, u16, CRC_16_LJ1200); define_crc_fn!(crc_16_maxim_dow, u16, CRC_16_MAXIM_DOW); define_crc_fn!(crc_16_mcrf4xx, u16, CRC_16_MCRF4XX); define_crc_fn!(crc_16_modbus, u16, CRC_16_MODBUS); define_crc_fn!(crc_16_nrsc_5, u16, CRC_16_NRSC_5); define_crc_fn!(crc_16_opensafety_a, u16, CRC_16_OPENSAFETY_A); define_crc_fn!(crc_16_opensafety_b, u16, CRC_16_OPENSAFETY_B); define_crc_fn!(crc_16_profibus, u16, CRC_16_PROFIBUS); define_crc_fn!(crc_16_riello, u16, CRC_16_RIELLO); define_crc_fn!(crc_16_spi_fujitsu, u16, CRC_16_SPI_FUJITSU); define_crc_fn!(crc_16_t10_dif, u16, CRC_16_T10_DIF); define_crc_fn!(crc_16_teledisk, u16, CRC_16_TELEDISK); define_crc_fn!(crc_16_tms37157, u16, CRC_16_TMS37157); define_crc_fn!(crc_16_umts, u16, CRC_16_UMTS); define_crc_fn!(crc_16_usb, u16, CRC_16_USB); define_crc_fn!(crc_16_xmodem, u16, CRC_16_XMODEM); define_crc_fn!(crc_16_ibm_refin, u16, CRC_16_IBM_REFIN); define_crc_fn!(crc_32_aixm, u32, CRC_32_AIXM); define_crc_fn!(crc_32_autosar, u32, CRC_32_AUTOSAR); define_crc_fn!(crc_32_base91_d, u32, CRC_32_BASE91_D); define_crc_fn!(crc_32_bzip2, u32, CRC_32_BZIP2); define_crc_fn!(crc_32_cd_rom_edc, u32, CRC_32_CD_ROM_EDC); define_crc_fn!(crc_32_cksum, u32, CRC_32_CKSUM); define_crc_fn!(crc_32_iscsi, u32, CRC_32_ISCSI); define_crc_fn!(crc_32_iso_hdlc, u32, CRC_32_ISO_HDLC); define_crc_fn!(crc_32_jamcrc, u32, CRC_32_JAMCRC); define_crc_fn!(crc_32_mpeg_2, u32, CRC_32_MPEG_2); define_crc_fn!(crc_32_xfer, u32, CRC_32_XFER); define_crc_fn!( crc_32_k_reversed_reciprocal_refin, u32, CRC_32_K_REVERSED_RECIPROCAL_REFIN ); define_crc_fn!(crc_64_ecma_182, u64, CRC_64_ECMA_182); define_crc_fn!(crc_64_go_iso, u64, CRC_64_GO_ISO); define_crc_fn!(crc_64_we, u64, CRC_64_WE); define_crc_fn!(crc_64_xz, u64, CRC_64_XZ); define_crc_fn!(crc_64_tms570_iso, u64, CRC_64_TMS570_ISO); #[pymodule(gil_used = false)] fn fastcrc(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(crc_8_autosar, m)?)?; m.add_function(wrap_pyfunction!(crc_8_bluetooth, m)?)?; m.add_function(wrap_pyfunction!(crc_8_cdma2000, m)?)?; m.add_function(wrap_pyfunction!(crc_8_darc, m)?)?; m.add_function(wrap_pyfunction!(crc_8_dvb_s2, m)?)?; m.add_function(wrap_pyfunction!(crc_8_gsm_a, m)?)?; m.add_function(wrap_pyfunction!(crc_8_gsm_b, m)?)?; m.add_function(wrap_pyfunction!(crc_8_i_432_1, m)?)?; m.add_function(wrap_pyfunction!(crc_8_i_code, m)?)?; m.add_function(wrap_pyfunction!(crc_8_lte, m)?)?; m.add_function(wrap_pyfunction!(crc_8_maxim_dow, m)?)?; m.add_function(wrap_pyfunction!(crc_8_mifare_mad, m)?)?; m.add_function(wrap_pyfunction!(crc_8_nrsc_5, m)?)?; m.add_function(wrap_pyfunction!(crc_8_opensafety, m)?)?; m.add_function(wrap_pyfunction!(crc_8_rohc, m)?)?; m.add_function(wrap_pyfunction!(crc_8_sae_j1850, m)?)?; m.add_function(wrap_pyfunction!(crc_8_smbus, m)?)?; m.add_function(wrap_pyfunction!(crc_8_tech_3250, m)?)?; m.add_function(wrap_pyfunction!(crc_8_wcdma, m)?)?; m.add_function(wrap_pyfunction!(crc_16_arc, m)?)?; m.add_function(wrap_pyfunction!(crc_16_cdma2000, m)?)?; m.add_function(wrap_pyfunction!(crc_16_cms, m)?)?; m.add_function(wrap_pyfunction!(crc_16_dds_110, m)?)?; m.add_function(wrap_pyfunction!(crc_16_dect_r, m)?)?; m.add_function(wrap_pyfunction!(crc_16_dect_x, m)?)?; m.add_function(wrap_pyfunction!(crc_16_dnp, m)?)?; m.add_function(wrap_pyfunction!(crc_16_en_13757, m)?)?; m.add_function(wrap_pyfunction!(crc_16_genibus, m)?)?; m.add_function(wrap_pyfunction!(crc_16_gsm, m)?)?; m.add_function(wrap_pyfunction!(crc_16_ibm_3740, m)?)?; m.add_function(wrap_pyfunction!(crc_16_ibm_sdlc, m)?)?; m.add_function(wrap_pyfunction!(crc_16_iso_iec_14443_3_a, m)?)?; m.add_function(wrap_pyfunction!(crc_16_kermit, m)?)?; m.add_function(wrap_pyfunction!(crc_16_lj1200, m)?)?; m.add_function(wrap_pyfunction!(crc_16_maxim_dow, m)?)?; m.add_function(wrap_pyfunction!(crc_16_mcrf4xx, m)?)?; m.add_function(wrap_pyfunction!(crc_16_modbus, m)?)?; m.add_function(wrap_pyfunction!(crc_16_nrsc_5, m)?)?; m.add_function(wrap_pyfunction!(crc_16_opensafety_a, m)?)?; m.add_function(wrap_pyfunction!(crc_16_opensafety_b, m)?)?; m.add_function(wrap_pyfunction!(crc_16_profibus, m)?)?; m.add_function(wrap_pyfunction!(crc_16_riello, m)?)?; m.add_function(wrap_pyfunction!(crc_16_spi_fujitsu, m)?)?; m.add_function(wrap_pyfunction!(crc_16_t10_dif, m)?)?; m.add_function(wrap_pyfunction!(crc_16_teledisk, m)?)?; m.add_function(wrap_pyfunction!(crc_16_tms37157, m)?)?; m.add_function(wrap_pyfunction!(crc_16_umts, m)?)?; m.add_function(wrap_pyfunction!(crc_16_usb, m)?)?; m.add_function(wrap_pyfunction!(crc_16_xmodem, m)?)?; m.add_function(wrap_pyfunction!(crc_16_ibm_refin, m)?)?; m.add_function(wrap_pyfunction!(crc_32_aixm, m)?)?; m.add_function(wrap_pyfunction!(crc_32_autosar, m)?)?; m.add_function(wrap_pyfunction!(crc_32_base91_d, m)?)?; m.add_function(wrap_pyfunction!(crc_32_bzip2, m)?)?; m.add_function(wrap_pyfunction!(crc_32_cd_rom_edc, m)?)?; m.add_function(wrap_pyfunction!(crc_32_cksum, m)?)?; m.add_function(wrap_pyfunction!(crc_32_iscsi, m)?)?; m.add_function(wrap_pyfunction!(crc_32_iso_hdlc, m)?)?; m.add_function(wrap_pyfunction!(crc_32_jamcrc, m)?)?; m.add_function(wrap_pyfunction!(crc_32_mpeg_2, m)?)?; m.add_function(wrap_pyfunction!(crc_32_xfer, m)?)?; m.add_function(wrap_pyfunction!(crc_32_k_reversed_reciprocal_refin, m)?)?; m.add_function(wrap_pyfunction!(crc_64_ecma_182, m)?)?; m.add_function(wrap_pyfunction!(crc_64_go_iso, m)?)?; m.add_function(wrap_pyfunction!(crc_64_we, m)?)?; m.add_function(wrap_pyfunction!(crc_64_xz, m)?)?; m.add_function(wrap_pyfunction!(crc_64_tms570_iso, m)?)?; Ok(()) } fastcrc-0.3.6/tea.yaml000066400000000000000000000002571517655752000146230ustar00rootroot00000000000000# https://tea.xyz/what-is-this-file --- version: 1.0.0 codeOwners: - '0x4CEF649407FDB92C118DcC8a9F53C5cbF9591d5A' - '0x3Dc76C3248A70e010339cb2F6F867831aB17366D' quorum: 1 fastcrc-0.3.6/tests/000077500000000000000000000000001517655752000143245ustar00rootroot00000000000000fastcrc-0.3.6/tests/test_fastcrc.py000066400000000000000000000335741517655752000173760ustar00rootroot00000000000000import unittest from fastcrc import crc8, crc16, crc32, crc64 data = b"123456789" data_part1 = b"1234" data_part2 = b"56789" class TestCrc8(unittest.TestCase): def test_bluetooth(self): self.assertEqual(38, crc8.bluetooth(data)) def test_bluetooth_init(self): self.assertEqual(38, crc8.bluetooth(data_part2, crc8.bluetooth(data_part1))) def test_cdma2000(self): self.assertEqual(218, crc8.cdma2000(data)) def test_cdma2000_init(self): self.assertEqual(218, crc8.cdma2000(data_part2, crc8.cdma2000(data_part1))) def test_darc(self): self.assertEqual(21, crc8.darc(data)) def test_darc_init(self): self.assertEqual(21, crc8.darc(data_part2, crc8.darc(data_part1))) def test_dvb_s2(self): self.assertEqual(188, crc8.dvb_s2(data)) def test_dvb_s2_init(self): self.assertEqual(188, crc8.dvb_s2(data_part2, crc8.dvb_s2(data_part1))) def test_gsm_a(self): self.assertEqual(55, crc8.gsm_a(data)) def test_gsm_a_init(self): self.assertEqual(55, crc8.gsm_a(data_part2, crc8.gsm_a(data_part1))) def test_gsm_b(self): self.assertEqual(148, crc8.gsm_b(data)) def test_gsm_b_init(self): self.assertEqual(148, crc8.gsm_b(data_part2, crc8.gsm_b(data_part1))) def test_i_432_1(self): self.assertEqual(161, crc8.i_432_1(data)) def test_i_432_1_init(self): self.assertEqual(161, crc8.i_432_1(data_part2, crc8.i_432_1(data_part1))) def test_i_code(self): self.assertEqual(126, crc8.i_code(data)) def test_i_code_init(self): self.assertEqual(126, crc8.i_code(data_part2, crc8.i_code(data_part1))) def test_lte(self): self.assertEqual(234, crc8.lte(data)) def test_lte_init(self): self.assertEqual(234, crc8.lte(data_part2, crc8.lte(data_part1))) def test_maxim_dow(self): self.assertEqual(161, crc8.maxim_dow(data)) def test_maxim_dow_init(self): self.assertEqual(161, crc8.maxim_dow(data_part2, crc8.maxim_dow(data_part1))) def test_mifare_mad(self): self.assertEqual(153, crc8.mifare_mad(data)) def test_mifare_mad_init(self): self.assertEqual(153, crc8.mifare_mad(data_part2, crc8.mifare_mad(data_part1))) def test_nrsc_5(self): self.assertEqual(247, crc8.nrsc_5(data)) def test_nrsc_5_init(self): self.assertEqual(247, crc8.nrsc_5(data_part2, crc8.nrsc_5(data_part1))) def test_opensafety(self): self.assertEqual(62, crc8.opensafety(data)) def test_opensafety_init(self): self.assertEqual(62, crc8.opensafety(data_part2, crc8.opensafety(data_part1))) def test_rohc(self): self.assertEqual(208, crc8.rohc(data)) def test_rohc_init(self): self.assertEqual(208, crc8.rohc(data_part2, crc8.rohc(data_part1))) def test_sae_j1850(self): self.assertEqual(75, crc8.sae_j1850(data)) def test_sae_j1850_init(self): self.assertEqual(75, crc8.sae_j1850(data_part2, crc8.sae_j1850(data_part1))) def test_smbus(self): self.assertEqual(244, crc8.smbus(data)) def test_smbus_init(self): self.assertEqual(244, crc8.smbus(data_part2, crc8.smbus(data_part1))) def test_tech_3250(self): self.assertEqual(151, crc8.tech_3250(data)) def test_tech_3250_init(self): self.assertEqual(151, crc8.tech_3250(data_part2, crc8.tech_3250(data_part1))) def test_wcdma(self): self.assertEqual(37, crc8.wcdma(data)) def test_wcdma_init(self): self.assertEqual(37, crc8.wcdma(data_part2, crc8.wcdma(data_part1))) class TestCrc16(unittest.TestCase): def test_arc(self): self.assertEqual(47933, crc16.arc(data)) def test_arc_init(self): self.assertEqual(47933, crc16.arc(data_part2, crc16.arc(data_part1))) def test_cdma2000(self): self.assertEqual(19462, crc16.cdma2000(data)) def test_cdma2000_init(self): self.assertEqual(19462, crc16.cdma2000(data_part2, crc16.cdma2000(data_part1))) def test_cms(self): self.assertEqual(44775, crc16.cms(data)) def test_cms_init(self): self.assertEqual(44775, crc16.cms(data_part2, crc16.cms(data_part1))) def test_dds_110(self): self.assertEqual(40655, crc16.dds_110(data)) def test_dds_110_init(self): self.assertEqual(40655, crc16.dds_110(data_part2, crc16.dds_110(data_part1))) def test_dect_r(self): self.assertEqual(126, crc16.dect_r(data)) def test_dect_r_init(self): self.assertEqual(126, crc16.dect_r(data_part2, crc16.dect_r(data_part1))) def test_dect_x(self): self.assertEqual(127, crc16.dect_x(data)) def test_dect_x_init(self): self.assertEqual(127, crc16.dect_x(data_part2, crc16.dect_x(data_part1))) def test_dnp(self): self.assertEqual(60034, crc16.dnp(data)) def test_dnp_init(self): self.assertEqual(60034, crc16.dnp(data_part2, crc16.dnp(data_part1))) def test_en_13757(self): self.assertEqual(49847, crc16.en_13757(data)) def test_en_13757_init(self): self.assertEqual(49847, crc16.en_13757(data_part2, crc16.en_13757(data_part1))) def test_genibus(self): self.assertEqual(54862, crc16.genibus(data)) def test_genibus_init(self): self.assertEqual(54862, crc16.genibus(data_part2, crc16.genibus(data_part1))) def test_gsm(self): self.assertEqual(52796, crc16.gsm(data)) def test_gsm_init(self): self.assertEqual(52796, crc16.gsm(data_part2, crc16.gsm(data_part1))) def test_ibm_3740(self): self.assertEqual(10673, crc16.ibm_3740(data)) def test_ibm_3740_init(self): self.assertEqual(10673, crc16.ibm_3740(data_part2, crc16.ibm_3740(data_part1))) def test_ibm_sdlc(self): self.assertEqual(36974, crc16.ibm_sdlc(data)) def test_ibm_sdlc_init(self): self.assertEqual(36974, crc16.ibm_sdlc(data_part2, crc16.ibm_sdlc(data_part1))) def test_iso_iec_14443_3_a(self): self.assertEqual(48901, crc16.iso_iec_14443_3_a(data)) def test_iso_iec_14443_3_a_init(self): self.assertEqual( 48901, crc16.iso_iec_14443_3_a(data_part2, crc16.iso_iec_14443_3_a(data_part1)), ) def test_kermit(self): self.assertEqual(8585, crc16.kermit(data)) def test_kermit_init(self): self.assertEqual(8585, crc16.kermit(data_part2, crc16.kermit(data_part1))) def test_lj1200(self): self.assertEqual(48628, crc16.lj1200(data)) def test_lj1200_init(self): self.assertEqual(48628, crc16.lj1200(data_part2, crc16.lj1200(data_part1))) def test_maxim_dow(self): self.assertEqual(17602, crc16.maxim_dow(data)) def test_maxim_dow_init(self): self.assertEqual( 17602, crc16.maxim_dow(data_part2, crc16.maxim_dow(data_part1)) ) def test_mcrf4xx(self): self.assertEqual(28561, crc16.mcrf4xx(data)) def test_mcrf4xx_init(self): self.assertEqual(28561, crc16.mcrf4xx(data_part2, crc16.mcrf4xx(data_part1))) def test_modbus(self): self.assertEqual(19255, crc16.modbus(data)) def test_modbus_init(self): self.assertEqual(19255, crc16.modbus(data_part2, crc16.modbus(data_part1))) def test_nrsc_5(self): self.assertEqual(41062, crc16.nrsc_5(data)) def test_nrsc_5_init(self): self.assertEqual(41062, crc16.nrsc_5(data_part2, crc16.nrsc_5(data_part1))) def test_opensafety_a(self): self.assertEqual(23864, crc16.opensafety_a(data)) def test_opensafety_a_init(self): self.assertEqual( 23864, crc16.opensafety_a(data_part2, crc16.opensafety_a(data_part1)) ) def test_opensafety_b(self): self.assertEqual(8446, crc16.opensafety_b(data)) def test_opensafety_b_init(self): self.assertEqual( 8446, crc16.opensafety_b(data_part2, crc16.opensafety_b(data_part1)) ) def test_profibus(self): self.assertEqual(43033, crc16.profibus(data)) def test_profibus_init(self): self.assertEqual(43033, crc16.profibus(data_part2, crc16.profibus(data_part1))) def test_riello(self): self.assertEqual(25552, crc16.riello(data)) def test_riello_init(self): self.assertEqual(25552, crc16.riello(data_part2, crc16.riello(data_part1))) def test_spi_fujitsu(self): self.assertEqual(58828, crc16.spi_fujitsu(data)) def test_spi_fujitsu_init(self): self.assertEqual( 58828, crc16.spi_fujitsu(data_part2, crc16.spi_fujitsu(data_part1)) ) def test_t10_dif(self): self.assertEqual(53467, crc16.t10_dif(data)) def test_t10_dif_init(self): self.assertEqual(53467, crc16.t10_dif(data_part2, crc16.t10_dif(data_part1))) def test_teledisk(self): self.assertEqual(4019, crc16.teledisk(data)) def test_teledisk_init(self): self.assertEqual(4019, crc16.teledisk(data_part2, crc16.teledisk(data_part1))) def test_tms37157(self): self.assertEqual(9905, crc16.tms37157(data)) def test_tms37157_init(self): self.assertEqual(9905, crc16.tms37157(data_part2, crc16.tms37157(data_part1))) def test_umts(self): self.assertEqual(65256, crc16.umts(data)) def test_umts_init(self): self.assertEqual(65256, crc16.umts(data_part2, crc16.umts(data_part1))) def test_usb(self): self.assertEqual(46280, crc16.usb(data)) def test_usb_init(self): self.assertEqual(46280, crc16.usb(data_part2, crc16.usb(data_part1))) def test_xmodem(self): self.assertEqual(12739, crc16.xmodem(data)) def test_xmodem_init(self): self.assertEqual(12739, crc16.xmodem(data_part2, crc16.xmodem(data_part1))) def test_ibm_refin(self): self.assertEqual(48349, crc16.ibm_refin(data)) def test_ibm_refin_init(self): self.assertEqual( 48349, crc16.ibm_refin(data_part2, crc16.ibm_refin(data_part1)) ) class TestCrc32(unittest.TestCase): def test_aixm(self): self.assertEqual(806403967, crc32.aixm(data)) def test_aixm_init(self): self.assertEqual(806403967, crc32.aixm(data_part2, crc32.aixm(data_part1))) def test_autosar(self): self.assertEqual(379048042, crc32.autosar(data)) def test_autosar_init(self): self.assertEqual( 379048042, crc32.autosar(data_part2, crc32.autosar(data_part1)) ) def test_base91_d(self): self.assertEqual(2268157302, crc32.base91_d(data)) def test_base91_d_init(self): self.assertEqual( 2268157302, crc32.base91_d(data_part2, crc32.base91_d(data_part1)) ) def test_bzip2(self): self.assertEqual(4236843288, crc32.bzip2(data)) def test_bzip2_init(self): self.assertEqual(4236843288, crc32.bzip2(data_part2, crc32.bzip2(data_part1))) def test_cd_rom_edc(self): self.assertEqual(1858268612, crc32.cd_rom_edc(data)) def test_cd_rom_edc_init(self): self.assertEqual( 1858268612, crc32.cd_rom_edc(data_part2, crc32.cd_rom_edc(data_part1)) ) def test_cksum(self): self.assertEqual(1985902208, crc32.cksum(data)) def test_cksum_init(self): self.assertEqual(1985902208, crc32.cksum(data_part2, crc32.cksum(data_part1))) def test_iscsi(self): self.assertEqual(3808858755, crc32.iscsi(data)) def test_iscsi_init(self): self.assertEqual(3808858755, crc32.iscsi(data_part2, crc32.iscsi(data_part1))) def test_iso_hdlc(self): self.assertEqual(3421780262, crc32.iso_hdlc(data)) def test_iso_hdlc_init(self): self.assertEqual( 3421780262, crc32.iso_hdlc(data_part2, crc32.iso_hdlc(data_part1)) ) def test_jamcrc(self): self.assertEqual(873187033, crc32.jamcrc(data)) def test_jamcrc_init(self): self.assertEqual(873187033, crc32.jamcrc(data_part2, crc32.jamcrc(data_part1))) def test_mpeg_2(self): self.assertEqual(58124007, crc32.mpeg_2(data)) def test_mpeg_2_init(self): self.assertEqual(58124007, crc32.mpeg_2(data_part2, crc32.mpeg_2(data_part1))) def test_xfer(self): self.assertEqual(3171672888, crc32.xfer(data)) def test_xfer_init(self): self.assertEqual(3171672888, crc32.xfer(data_part2, crc32.xfer(data_part1))) def test_k_reversed_reciprocal_refin(self): self.assertEqual( 2493346179, crc32.k_reversed_reciprocal_refin(data), ) def test_k_reversed_reciprocal_refin_init(self): self.assertEqual( 2493346179, crc32.k_reversed_reciprocal_refin( data_part2, crc32.k_reversed_reciprocal_refin(data_part1) ), ) class TestCrc64(unittest.TestCase): def test_ecma_182(self): self.assertEqual(7800480153909949255, crc64.ecma_182(data)) def test_ecma_182_init(self): self.assertEqual( 7800480153909949255, crc64.ecma_182(data_part2, crc64.ecma_182(data_part1)) ) def test_go_iso(self): self.assertEqual(13333283586479230977, crc64.go_iso(data)) def test_go_iso_init(self): self.assertEqual( 13333283586479230977, crc64.go_iso(data_part2, crc64.go_iso(data_part1)) ) def test_we(self): self.assertEqual(7128171145767219210, crc64.we(data)) def test_we_init(self): self.assertEqual( 7128171145767219210, crc64.we(data_part2, crc64.we(data_part1)) ) def test_xz(self): self.assertEqual(11051210869376104954, crc64.xz(data)) def test_xz_init(self): self.assertEqual( 11051210869376104954, crc64.xz(data_part2, crc64.xz(data_part1)) ) def test_tms570_iso(self): self.assertEqual(16501117177879017360, crc64.tms570_iso(data)) def test_tms570_iso_init(self): self.assertEqual( 16501117177879017360, crc64.tms570_iso(data_part2, crc64.tms570_iso(data_part1)), ) if __name__ == "__main__": unittest.main()