Created
February 3, 2018 09:38
-
-
Save superjohan/c46919c90dac8d8b319545594ea7ba58 to your computer and use it in GitHub Desktop.
create md5+sha1 digests for maven purposes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
import click | |
import hashlib | |
import os | |
@click.command() | |
@click.argument('filename') | |
def write_digests(filename): | |
if not os.path.exists(filename): | |
print('File {} not found'.format(filename)) | |
return -1 | |
file = open(filename, 'rb').read() | |
md5 = hashlib.md5() | |
md5.update(file) | |
with open('{}.md5'.format(filename), 'w') as md5file: | |
md5file.write(md5.hexdigest()) | |
sha1 = hashlib.sha1() | |
sha1.update(file) | |
with open('{}.sha1'.format(filename), 'w') as sha1file: | |
sha1file.write(sha1.hexdigest()) | |
if __name__ == '__main__': | |
write_digests() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment