Skip to content

Conversation

@code-inflation
Copy link
Owner

Summary

Add new CRC32C variant and file processing capabilities with enhanced Hasher features.

New Features

  • CRC32C support: Add crc32c() function using Castagnoli polynomial (common in iSCSI, Ethernet)
  • File processing: Add crc32_file() and crc32_fileobj() functions for convenient file checksumming
  • Enhanced Hasher:
    • copy() method for creating independent hasher copies
    • Context manager support (with Hasher() as h:)
    • __len__() method to track bytes processed
    • __repr__() method for debugging
  • Improved error handling: Clear, helpful error messages for common usage mistakes
  • Type safety: Full type hints with .pyi stub file for IDE support

API Changes

# New CRC32C variant
from pycrc32 import crc32c
result = crc32c(b"data")

# File processing
from pycrc32 import crc32_file, crc32_fileobj
file_crc = crc32_file("/path/to/file")
obj_crc = crc32_fileobj(file_object)

# Enhanced Hasher features
hasher = Hasher()
hasher.update(b"data")
print(len(hasher))  # Bytes processed
copy_hasher = hasher.copy()

with Hasher() as h:
    h.update(b"context")

@code-inflation code-inflation self-assigned this Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants