Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- hexchars = "0123456789abcdef"
- oldindex = None
- while True:
- x = sys.stdin.read(1)
- if not x:
- break
- x = x.lower()
- if x not in hexchars:
- continue
- i = hexchars.index(x)
- if oldindex is None:
- oldindex = i
- else:
- n = (oldindex << 4) | i
- sys.stdout.write("%c" % n)
- oldindex = None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement