sigmf.hashing.calculate_sha512
- sigmf.hashing.calculate_sha512(filename=None, fileobj=None, offset=0, size=None)
Calculate SHA512 hash of a dataset for integrity verification.
The entire recording file should be hashed according to the SigMF specification.
- Parameters:
filename (str or Path, optional) – Path to the file to hash. If provided, the file will be opened and hashed. Cannot be used together with fileobj.
fileobj (file-like object, optional) – An open file-like object (e.g., BytesIO) to hash. Must have read() and seek() methods. Cannot be used together with filename.
offset (int, optional) – Byte offset into the file to start hashing from. Default is 0.
size (int, optional) – Number of bytes to hash. If None, hash from offset to end of file.
- Returns:
128 character hex digest (512 bits).
- Return type:
- Raises:
ValueError – If neither filename nor fileobj is provided.