Skip to content

Instantly share code, notes, and snippets.

@laanwj
Created October 30, 2015 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laanwj/3a142c48046ef862bf91 to your computer and use it in GitHub Desktop.
Save laanwj/3a142c48046ef862bf91 to your computer and use it in GitHub Desktop.
sha256sum w/ unicode block elements
#!/usr/bin/python3
# W.J. 2015 (License: MIT)
import hashlib,sys,os
BLOCKCHARS = '\u0020\u2598\u259d\u2580\u2596\u258c\u259e\u259b\u2597\u259a\u2590\u259c\u2584\u2599\u259f\u2588'
def uhex(x):
return ''.join(BLOCKCHARS[b>>4] + BLOCKCHARS[b&0xf] for b in x)
for filename in sys.argv[1:]:
if not os.path.isfile(filename):
continue
with open(filename, 'rb') as f:
h = hashlib.sha256()
while True:
r = f.read(4096)
if not r:
break
h.update(r)
print(uhex(h.digest()), filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment