Return a checksum from the content of the file at ``location`` using the ``name`` checksum algorithm. The checksum is a string as a hexdigest or is base64-encoded is ``base64`` is True. Return None if ``location`` is not a file or an empty file.
(location, name, base64=False)
| 215 | |
| 216 | |
| 217 | def checksum(location, name, base64=False): |
| 218 | """ |
| 219 | Return a checksum from the content of the file at ``location`` using the ``name`` checksum |
| 220 | algorithm. The checksum is a string as a hexdigest or is base64-encoded is ``base64`` is True. |
| 221 | |
| 222 | Return None if ``location`` is not a file or an empty file. |
| 223 | """ |
| 224 | if not filetype.is_file(location): |
| 225 | return |
| 226 | |
| 227 | total_length = get_file_size(location) |
| 228 | chunks = binary_chunks(location) |
| 229 | return checksum_from_chunks(chunks=chunks, total_length=total_length, name=name, base64=base64) |
| 230 | |
| 231 | |
| 232 | def checksum_from_chunks(chunks, name, total_length=0, base64=False): |