Advertisement
jdaher

A858 AMA Decoder

Apr 29th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4.  
  5. with open("key") as f:
  6.         key_lines = f.readlines()
  7.  
  8. msg = sys.argv[1]
  9.  
  10. outchars = ""
  11. for i in range(len(msg) / 4):
  12.         x = int(msg[i*4:i*4+2], 16)
  13.         y = int(msg[i*4+2:i*4+4], 16)
  14.         line = key_lines[y]
  15.         outchars += "%c" % line[x]
  16.  
  17. i = 0
  18. while i < len(outchars):
  19.         if outchars[i] == '1':
  20.                 num = outchars[i:i+3]
  21.                 i += 3
  22.         else:
  23.                 num = outchars[i:i+2]
  24.                 i += 2
  25.         sys.stdout.write("%c" % int(num))
  26.  
  27. print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement