Peer review: Python encyphering script

A. Jones netzapper at magicstar.net
Wed Feb 27 22:18:01 EST 2002


It's my second day Pythoning and I've written this code to encypher
text (or files, ostensibly) into two pieces, neither of which can be
used to determine the message.

Any problems pointed out, clunky lines spotted, or security problems
would be most appreciated.  Also, if you've seen something like this,
if you'd tell me, please.

For now, no interface, just C&P between sessions of IDLE.

ASCII converts to numbers because of future security measures (such as
inserting chunks of random data to pad small messages, which would
then automatically delete themselves in the process of decrypting
using multiplication by 0)

Source below.

---

#encyphering tool 
plaintext = "Isn't it awfully nice to have a penis; isn't it
frightfully good to have it on!" #The variable makes it obvious.
blarg = [] #To hold translation of ASCII to num
for b in plaintext:
#    print b #Was here for development purposes.
    blarg.append(ord(b)) #Turn it into a list of ASCII numbers
                         #nums make sorting easier&append/ord makes a
nice list
plaintext = "Text purged."

blurb = {} #To hold 1:1 value/offset references
b = 0 #reuse variable so's to destroy evidence/make my life easier
for z in blarg:
    if z in blurb: #duplicate key fixer
            if type(blurb[z]) == "<type 'list'>": #Stops nesting
strings
                blurb[z].append(b)
            else:
                temp = blurb[z] #Used to create first list entry
                temp.append(b)
                blurb[z] = temp
    else: blurb[z] = [b] #sets dictionary with values as keys, offsets
as objects
    b = b+1 #Next step in the offset counter... clunky.

valuelist = blurb.keys() #extract keys of dictionary
valuelist.sort() #to be randomized later(date)

finval = [] #to hold final value list
finoff = [] #to hold final offset list
for r in valuelist:
    z = 0
    while z < len(blurb[r]): #Writes number of values equal to number
of offsets
        finval.append(r)
        z = z+1
    for q in blurb[r]: #Decomposes my clunky nesting lists/dicts
        finoff.append(q)

blurb = {}  #Destroy the evidence!
valuelist = []

--
#decyphering tool
text = [] #finval
key = [] #finoff
numdict = {}
z = 0
for r in key: #This here is the heart of the decryption process.
Simply coalates the lists.
    numdict[r] = text[z]
    z = z + 1
readlist = numdict.keys()
readlist.sort() #puts the keys/offsets in order
plaintext = ""
for r in readlist:
    plaintext = plaintext + chr(numdict[r])
print plaintext #prints plaintext
---

Aubrey Jones
______________________________________________________________________________
Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net



More information about the Python-list mailing list