Use gpg2 to sign the checksum file.
This commit is contained in:
+12
-3
@@ -3,6 +3,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def hash_all(f, hash_name, hash_func, directory):
|
def hash_all(f, hash_name, hash_func, directory):
|
||||||
@@ -26,7 +27,7 @@ def hash_all(f, hash_name, hash_func, directory):
|
|||||||
|
|
||||||
h = hash_func(data)
|
h = hash_func(data)
|
||||||
f.write("{} {}\n".format(h.hexdigest(), fn))
|
f.write("{} {}\n".format(h.hexdigest(), fn))
|
||||||
print(h.hexdigest(), fn)
|
# print(h.hexdigest(), fn)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -36,12 +37,20 @@ def main():
|
|||||||
|
|
||||||
hashes = [ ("md5", hashlib.md5), ("sha1", hashlib.sha1), ("sha256", hashlib.sha256) ]
|
hashes = [ ("md5", hashlib.md5), ("sha1", hashlib.sha1), ("sha256", hashlib.sha256) ]
|
||||||
|
|
||||||
with open(os.path.join(args.directory, "checksums.txt"), "w") as f:
|
checksum_fn = os.path.join(args.directory, "checksums.txt")
|
||||||
|
|
||||||
f.write("# Warning: These can be used to verify file integrity, but are not signed.\n")
|
with open(checksum_fn, "w") as f:
|
||||||
|
|
||||||
for name, func in hashes:
|
for name, func in hashes:
|
||||||
hash_all(f, name, func, args.directory)
|
hash_all(f, name, func, args.directory)
|
||||||
|
|
||||||
|
f.write("\n\n")
|
||||||
|
|
||||||
|
if os.path.exists(checksum_fn + ".asc"):
|
||||||
|
os.unlink(checksum_fn + ".asc")
|
||||||
|
|
||||||
|
subprocess.check_call([ "gpg2", "--clearsign", checksum_fn ])
|
||||||
|
os.rename(checksum_fn + ".asc", checksum_fn)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user