]> git.somenet.org - pub/jan/scripts.git/blob - hax/somedecode.py
use bug to generate deltat-game-credits.
[pub/jan/scripts.git] / hax / somedecode.py
1 #!/usr/bin/env python
2
3 import sys
4 import os
5 import signal
6 import csv
7 import binascii
8
9
10 def somedecode(infilename, outfilename):
11   with open(infilename, 'r') as infile:
12     infilestr=infile.read()
13
14   bitstrstr = ""
15
16   for c in infilestr:
17     if c in "abcdefghinjklmnopqrstuvwxyz":
18       bitstrstr += "0"
19     elif c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
20       bitstrstr += "1"
21     else:
22       pass
23   
24   bitstrstr = bitstrstr[:-(len(bitstrstr)%8)]
25
26   print(bitstrstr)
27
28   retstr = binascii.unhexlify('%x' % int(bitstrstr, 2))
29   open(outfilename, 'w').write(retstr.decode())
30
31
32 if __name__ == "__main__":
33         def signal_handler(signal, frame):
34                 print('SIG received. exitting!')
35                 sys.exit(0)
36         signal.signal(signal.SIGINT, signal_handler)
37
38         somedecode("out.txt", "dec.txt")
39