mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-20 02:05:30 -04:00
BIOSUtilities v24.10.01
Complete repository overhaul into python project Re-designed BIOSUtility base template class flow Re-structured utilities as BIOSUtility inherited Re-structured project for 3rd-party compatibility Unified project requirements and package version Code overhaul with type hints and linting support Switched external executable dependencies via PATH BIOSUtility enforces simple check and parse methods Utilities now work with both path and buffer inputs Adjusted class, method, function names and parameters Improved Dell PFS Update Extractor sub-PFAT processing Improved Award BIOS Module Extractor corruption handling Improved Apple EFI Image Identifier to expose the EFI ID Improved Insyde iFlash/iFdPacker Extractor with ISH & PDT Re-written Apple EFI Package Extractor to support all PKG
This commit is contained in:
parent
ef50b75ae1
commit
cda2fbd0b1
65 changed files with 6239 additions and 5233 deletions
31
biosutilities/common/checksums.py
Normal file
31
biosutilities/common/checksums.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python3 -B
|
||||
# coding=utf-8
|
||||
|
||||
"""
|
||||
Copyright (C) 2022-2024 Plato Mavropoulos
|
||||
"""
|
||||
|
||||
|
||||
# Get Checksum 16-bit
|
||||
def checksum_16(data: bytes | bytearray, value: int = 0, order: str = 'little') -> int:
|
||||
""" Calculate Checksum-16 of data, controlling IV and Endianess """
|
||||
|
||||
for idx in range(0, len(data), 2):
|
||||
# noinspection PyTypeChecker
|
||||
value += int.from_bytes(bytes=data[idx:idx + 2], byteorder=order) # type: ignore
|
||||
|
||||
value &= 0xFFFF
|
||||
|
||||
return value
|
||||
|
||||
|
||||
# Get Checksum 8-bit XOR
|
||||
def checksum_8_xor(data: bytes | bytearray, value: int = 0) -> int:
|
||||
""" Calculate Checksum-8 XOR of data, controlling IV """
|
||||
|
||||
for byte in data:
|
||||
value ^= byte
|
||||
|
||||
value ^= 0x0
|
||||
|
||||
return value
|
Loading…
Add table
Add a link
Reference in a new issue