hbc/pywii/pywii-tools/addhash.py

12 lines
262 B
Python
Raw Normal View History

2021-03-17 15:53:31 +01:00
#!/usr/bin/env python3
2016-11-23 06:35:12 +01:00
import sys
import re
import pywii as wii
hash = wii.SHA.new(open(sys.argv[2]).read()).digest().encode("hex")
2021-03-17 15:53:31 +01:00
f = open(sys.argv[1], "rb")
2016-11-23 06:35:12 +01:00
data = f.read()
f.close()
data = re.sub('@SHA1SUM@', hash, data)
2021-03-17 15:53:31 +01:00
open(sys.argv[3], "wb").write(data)