-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchecksummaker.py
More file actions
executable file
·33 lines (26 loc) · 864 Bytes
/
checksummaker.py
File metadata and controls
executable file
·33 lines (26 loc) · 864 Bytes
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
#!/usr/bin/env python
"""checksummaker.py: Creates SHA1 checksums of datalogger.py versions and adds to goodchecksums.txt, sunfinder.py
uses goodchecksums.txt to validate signatiures including checksums"""
__author__ = "Steven Campbell AKA Scalextrix"
__copyright__ = "Copyright 2018, Steven Campbell"
__license__ = "The Unlicense"
__version__ = "1.0"
import hashlib
import os.path
manufacturer = ["Enphase", "GoodWe", "SolarEdge"]
def checksum():
hasher = hashlib.sha1()
with open('{}/datalogger.py'.format(manufacturer[counter]), 'rb') as afile:
buf = afile.read()
hasher.update(buf)
return (hasher.hexdigest())
f = open("sunfinder/goodchecksums.txt","a+")
hashlist = f.read().splitlines()
counter = 0
while True:
if checksum() not in hashlist:
f.write(checksum()+'\n')
counter = counter+1
if counter == len(manufacturer):
f.close()
break