add colors to hex hash values

This commit is contained in:
Roman Zeyde
2014-07-19 12:04:36 +03:00
parent 72cb102775
commit 500f956c43

17
colorhash.py Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env python
import sys
import binascii
lines = sys.stdin.read().strip().split('\n')
for line in lines:
head, tail = line.split(' ', 1)
bars = ''
try:
data = binascii.unhexlify(head)
data = map(ord, data)
bars = ['\033[48;5;%dm \033[m' % (x,) for x in data]
bars = '{{{}}}'.format(''.join(bars))
except TypeError:
pass
print('%s %s %s' % (head, tail, bars))