[Python] Python checksum calculation ideas

Discussão em 'Python' iniciado por Stack, Dezembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    I have an excel file containing data. I'm looking for a simple way to ensure that this data has not been modified. How can I do this using Python (2.x and 3.x)?

    EDIT

    I've simplified the question because leaving only what I actually needed at the time. Simple solution to do such things is to use existing checksum calculation libraries on the file content.

    Example using SHA512 in Linux:

    sha512sum excel_file.xlsx


    Example in Python, giving the same result as above:

    import hashlib

    h = hashlib.sha512()
    with open('crc.py', 'rb') as f:
    contents = f.read()
    h.update(contents)
    print(h.hexdigest())

    Continue reading...

Compartilhe esta Página