Implement --fingerprint option for manual fingerprint checking

This commit is contained in:
Kristóf Tóth 2022-02-14 01:32:12 +01:00
parent 7de587148e
commit 3179be1f76
1 changed files with 10 additions and 3 deletions

13
main.py
View File

@ -28,6 +28,10 @@ BUF_SIZE = 65536 # Linux default pipe capacity is 64KiB (64 * 2^10)
'--file', '-f', default=None, type=click.Path(exists=True),
help='Calculate from file or directory (recursive).'
)
@click.option(
'--fingerprint', '-p', default=False, required=False, is_flag=True,
help='Print fingerprint instead of identicon.'
)
def main(**kwargs):
if not (stream := get_input_stream(kwargs)):
print_usage_and_exit()
@ -35,9 +39,12 @@ def main(**kwargs):
digest = get_digest(stream.stream)
stream.close()
i = Identicon(digest)
i.calculate()
print(i)
if not kwargs.get('fingerprint'):
i = Identicon(digest)
i.calculate()
print(i)
else:
print(digest.hex())
def get_input_stream(kwargs):