-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathchecksum.py
executable file
·46 lines (33 loc) · 1.05 KB
/
checksum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
# calculate checksum for files
# Copyright 2018, Aswin Babu Karuvally
# import serious stuff
import zlib
import argparse
# read and return list of files
def read_file_list(file_list_path):
try:
file_list_file = open(file_list_path, "r")
list_of_files = [line.rstrip() for line in file_list_file]
file_list_file.close()
except:
print("error: unable to load list of files")
return list_of_files
# generate checksum of files
# the main function
def main():
# read the run-time arguments
parser = argparse.ArgumentParser(description =
"Looks for changes in files")
parser.add_argument("file_list", help = "specify path to file list")
arguments = parser.parse_args()
# read list of files
list_of_files = read_file_list(arguments.file_list)
# generate crc of each file
crc_list = []
# check if file already has hash in database
# if not, create the entry in db
# cross check both hashes
# alert user if change in hash
# run the main function
main()