Created
January 19, 2020 19:15
-
-
Save ajkerrigan/7bd8f0c14543b7a78a68b71e95b8d5a1 to your computer and use it in GitHub Desktop.
vdhash.py
This file contains hidden or 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/bin/env python3 | |
| import hashlib | |
| import sys | |
| from pathlib import Path | |
| if len(sys.argv) != 2: | |
| print(f'Usage: {sys.argv[0]} <file>') | |
| sys.exit(1) | |
| try: | |
| p = Path(sys.argv[1]) | |
| # Strip and hash, matching the behavior of VisiData's plugin checker: | |
| # https://github.com/saulpw/visidata/blob/v2.-2.0/visidata/plugins.py#L46-L48 | |
| print(hashlib.sha256(p.read_bytes().strip()).hexdigest()) | |
| except FileNotFoundError as err: | |
| print(f"Can't find file: {err.filename}") | |
| sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment