shippinglabel.checksum

Utilities for creating and checking file sha256 checksums.

New in version 0.6.0.

Functions:

get_sha256_hash(filename[, blocksize])

Returns the SHA256 hash object for the given file.

check_sha256_hash(filename, hash[, blocksize])

Returns whether the SHA256 hash for the file matches hash.

get_md5_hash(filename[, blocksize])

Returns the md5 hash object for the given file.

get_record_entry(filename[, blocksize, …])

Constructs a PEP 376 RECORD entry for the file.

get_sha256_hash(filename, blocksize=1048576)[source]

Returns the SHA256 hash object for the given file.

New in version 0.6.0.

Parameters
Return type

hashlib.sha256()

Changed in version 0.16.0: Added support for already open file objects.

check_sha256_hash(filename, hash, blocksize=1048576)[source]

Returns whether the SHA256 hash for the file matches hash.

New in version 0.6.0.

Parameters
Return type

bool

Changed in version 0.16.0: Added support for already open file objects.

get_md5_hash(filename, blocksize=1048576)[source]

Returns the md5 hash object for the given file.

New in version 0.15.0.

Parameters
Return type

hashlib.md5()

Changed in version 0.16.0: Added support for already open file objects.

get_record_entry(filename, blocksize=1048576, relative_to=None)[source]

Constructs a PEP 376 RECORD entry for the file.

New in version 0.6.0.

Parameters
Return type

str