-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from us-irs/refactor-and-fix-crc-handling
Refactor and fix crc handling
- Loading branch information
Showing
12 changed files
with
207 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import struct | ||
from pathlib import Path | ||
|
||
|
||
def calc_modular_checksum(file_path: Path) -> bytes: | ||
"""Calculates the modular checksum for a file in one go.""" | ||
checksum = 0 | ||
|
||
with open(file_path, "rb") as file: | ||
while True: | ||
data = file.read(4) | ||
if not data: | ||
break | ||
checksum += int.from_bytes( | ||
data.ljust(4, b"\0"), byteorder="big", signed=False | ||
) | ||
|
||
checksum %= 2**32 | ||
return struct.pack("!I", checksum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.