Skip to content

Instantly share code, notes, and snippets.

@superjohan
Created February 3, 2018 09:38
Show Gist options
  • Save superjohan/c46919c90dac8d8b319545594ea7ba58 to your computer and use it in GitHub Desktop.
Save superjohan/c46919c90dac8d8b319545594ea7ba58 to your computer and use it in GitHub Desktop.
create md5+sha1 digests for maven purposes
#!/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