maci docs
  • maci
  • WATCH
    • Quick Start
    • Full Training Series
  • DOCS
    • maci
      • language
        • v1.0.0
      • functions
        • maci.build
        • maci.load
        • maci.loadstr
        • maci.loadattrs
        • maci.loadraw
        • maci.loaddict
        • maci.loadstrdict
        • maci.dump
        • maci.dumpstr
        • maci.dumpraw
      • object
        • methods
          • lock_attr
          • unlock_attr
          • hard_lock_attr
          • map_attr
          • unmap_attr
          • load_attrs
          • get_attrs
          • get_locked_list
          • get_hard_locked_list
          • get_all_maps
          • get_parent_maps
          • get_child_maps
          • get_parent_map_chains
          • is_parent_map
          • is_child_map
      • errors
      • hints
    • json
      • functions
        • maci.jsonload
        • maci.jsonloadstr
        • maci.jsondump
        • maci.jsondumpstr
    • yaml
      • functions
        • maci.yamlload
        • maci.yamlloadstr
        • maci.yamlloadall
        • maci.yamldump
        • maci.yamldumpstr
        • maci.yamldumpall
    • toml
      • functions
        • maci.tomlload
        • maci.tomlloadstr
        • maci.tomldump
        • maci.tomldumpstr
    • ini
      • functions
        • maci.iniload
        • maci.inidump
        • maci.inibuildauto
        • maci.inibuildmanual
    • xml
      • functions
        • maci.xmlload
        • maci.xmlloadstr
        • maci.xmlloaddict
        • maci.xmlloadstrdict
        • maci.xmldump
        • maci.xmldumpstr
        • maci.xmldumpdict
        • maci.xmldumpstrdict
        • maci.xmlbuildmanual
        • maci._defuse_xml_stdlib
    • pickle
      • functions
        • maci.pickleloadbytes
        • maci.pickledumpbytes
    • tools
      • hash functions
        • maci.createhash
        • maci.createfilehash
        • maci.comparefilehash
      • format functions
        • maci.cleanformat
  • Updates
    • Changelog
      • v1.1.0
      • v1.0.0
Powered by GitBook
On this page
  • partner functions
  • parameters & arguments
  1. DOCS
  2. tools
  3. hash functions

maci.comparefilehash

compare hash of file to stored hash

Last updated 1 year ago

Compares a hash of the source file against the previously created file with the stored hash data, from using the partner function, and returns a boolean if the hashes match.

maci.comparefilehash -> bool

Basic Example of comparing hash of a file against the stored hash using default positional parameters

result = maci.comparefilehash(src_file, dst_file)

In this example, we simply input the source file to hash and the destination file with the stored hash data using the comparefilehash function and pass the file locations as arguments to the function, the hashed data is then compared against the source file, and assign the returned result to a variable.

To create the initial stored hashed data, see the partner function . This tool is designed to dependently work with its partner function.

partner functions

Functions that are related for comparefilehash

-> Creates hash of a file, and stores the hash data to a newly created file

parameters & arguments

Describes all parameter functionality and accepted data types

file_to_hash: str | Path

First required positional argument. Accepts strings and

Use this parameter to point to your source filepath to get the hash.

stored_hash_file: str | Path

Use this parameter to point to your destination filepath of the file with the stored hash data.

hash_algorithm: str

Optional parameter. Accepts strings. Default = 'sha256'

Use this parameter to set the hash algorithm used for the hash. Default is sha256, which is a current common industry standard.

All options available: 'sha256', 'sha512', 'sha384', 'sha1', 'md5'

encoding: str | None

Optional parameter. Accepts strings or None. Default = None

Use this parameter to set the source file hashed data and the destination file containing the hashed data with the desired codec if needed. The default uses the default of python, so you don't have to use this, but you can if the data needs to be written with a specific codec.

Second required positional argument. Accepts strings and

createfilehash
createfilehash
maci.createfilehash
Path objects
Path objects