[ create a new paste ] login | about

Link: http://codepad.org/giUmYAy0    [ raw code | fork ]

Python, pasted on Jul 27:
#!/usr/bin/env python
#
# undsi - UNencode Dritek System Inc encoding
#
# b3nn - 20110410-01
# Updated to Python 3.0 and shortned the decode table with Python power - the maddman 20110727

import os
import sys
import getopt
import string

#[::] is stride notation for sequences, [::-1] returns the string starting from the end with a stride of 1, reversing the string
one = string.ascii_letters+"0123456789"
two = string.ascii_letters[::-1]+"9876543210"
disdecode = dict(zip(one,two))

# Setup Decoding Loop for a word   

def decode(input):
	decode = ""
	for c in str(input):
		decode += disdecode.get(c,c)
	return decode

# My test word
input = "xLKBIRTSG"

# Parse the commandline
try:
    (options, arguments) = getopt.getopt(sys.argv[1:],'')
except getopt.GetoptError as ex:
    sys.exit(1)
    
# Select the input source
if arguments:
	try:
		fd = open(arguments[0])
	except Exception as ex:
		input = arguments[0]
		sys.stderr.write("File not found '%s'. Using single word decrypt.\n   Decoded Word: " %(arguments[0]))
		print(decode(input))
		sys.exit(1)
# Decode a file   
	while 1:
		line = fd.readline()
		if not len(line):
			break
		print(decode(line.strip()))
else:
	print("Decoding test word: %s = %s"%(input,decode(input)))


Create a new paste based on this one


Comments: