DRF to TXT
Python
code posted
created at 01 Jun 15:22, updated at 01 Jun 18:47
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#------------------------------------------------------------------------------- # Name: drf2txt # Purpose: Decodes a Control-M DRF file to text # # # Created: 16/03/2008 # Licence: public domain # see : http://www.control-musage.com/modules.php?name=Forums&file=viewtopic&t=248 # Comment: Currently only decrypts, but should be easy to make it re-crypt. #------------------------------------------------------------------------------- #!/usr/bin/env python import sys def decryptChar(x,idx): if idx % 2 == 0: return chr(ord(x) - 2) else: return chr(ord(x) + 2) def cryptChar(x,idx): if idx % 2 == 0: return chr(ord(x) + 2) else: return chr(ord(x) - 2) def main(): line_number = 0 for line in file(sys.argv[1], "rU"): if line_number > 0: newline = [] char_number = 0 for c in line[line.find(';')+1:-1]: newline.append(decryptChar(c, char_number)) char_number += 1 element = ''.join(newline) print element else: pass line_number += 1 if __name__ == '__main__': if (len(sys.argv) > 1): main() |
1.23 KB in 3 ms with coderay