mirror of
https://github.com/romanz/amodem.git
synced 2026-03-18 07:36:02 +08:00
add colors to hex hash values
This commit is contained in:
17
colorhash.py
Executable file
17
colorhash.py
Executable 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))
|
||||
Reference in New Issue
Block a user