Last active
January 23, 2023 21:01
-
-
Save moreati/0d4560eabfa910ba2e69f95c4f771365 to your computer and use it in GitHub Desktop.
List sha256 digests and names in a .tar piped to stdin
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/bin/env/python3 | |
import hashlib | |
import sys | |
import tarfile | |
with tarfile.open(fileobj=sys.stdin.buffer, mode='r|') as tf: | |
for member in tf: | |
if member.isfile(): | |
with tf.extractfile(member) as mf: | |
mh = hashlib.sha256(mf.read()) | |
print(mh.hexdigest(), member.name) |
Author
moreati
commented
Jan 23, 2023
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment