#!/usr/bin/env python # encoding: utf-8 """ untitled.py Created by Cody Brocious on 2006-09-10. Copyright (c) 2006 __MyCompanyName__. All rights reserved. """ import sys import os alpha = list('DF4709156BC8A23E') mapping = {} counter = 0 for c in alpha: mapping[c] = counter counter += 1 def main(): while True: try: code = raw_input('Code: ') except: print '' break code = code.upper() code = code.replace('-', '') chars = [mapping[c] for c in code] value = (chars[0] << 4) | chars[1] a = (chars[2] << 4) | chars[3] b = (chars[4] << 4) | chars[5] c = (chars[6] << 4) | chars[7] total = (a << 16) | (b << 8) | c mn = total & 0x3 total >>= 2 gh = total & 0x3 total >>= 2 ef = total & 0x3 total >>= 2 wx = total & 0x3 total >>= 2 uv = total & 0x3 total >>= 2 cd = total & 0x3 total >>= 2 ab = total & 0x3 total >>= 2 op = total & 0x3 total >>= 2 st = total & 0x3 total >>= 2 qr = total & 0x3 total >>= 2 kl = total & 0x3 total >>= 2 ij = total & 0x3 total >>= 2 result = 0 result <<= 2 result |= ab result <<= 2 result |= cd result <<= 2 result |= ef result <<= 2 result |= gh result <<= 2 result |= ij result <<= 2 result |= kl result <<= 2 result |= mn result <<= 2 result |= op result <<= 2 result |= qr result <<= 2 result |= st result <<= 2 result |= uv result <<= 2 result |= wx print '0x%06x == 0x%02x' % (result, value) if __name__ == '__main__': main()