from pathlib import Path
import hashlib


def calculate_hash_fingerprint(file):
    """
    Calculate the sha-256 fingerprint of the attached file
    :param file: the attached file
    :return: the fingerprint
    """
    if file is not None and Path(file.path).exists():
        file.open(mode='rb')
        digest = hashlib.sha256(file.read()).digest()
        file.close()
        return digest
    return hashlib.sha256().digest()