10 def someencode(infilename, strfilename, outfilename):
11 with open(infilename, 'r') as infile:
12 infilestr=infile.read()
13 with open(strfilename, 'r') as strfile:
14 strfilestr=strfile.read().strip()
16 bitstrstr = "".join(["{0:08b}".format(ord(i)) for i in strfilestr ])
25 if bit >= len(bitstrstr):
27 elif c not in "abcdefghinjklmnopqrstuvwxyz":
29 elif bitstrstr[bit] == "1":
30 retstr = retstr + chr(ord(c)-32)
36 if bit < len(bitstrstr):
37 print("SOME PAYLOAD NOT ENCODED!")
38 open(outfilename, 'w').write(retstr)
41 if __name__ == "__main__":
42 def signal_handler(signal, frame):
43 print('SIG received. exitting!')
45 signal.signal(signal.SIGINT, signal_handler)
47 someencode("in.txt", "str.txt", "out.txt")