Unusual behavior with rotor

Jeff Sykes jeff at cowz.com
Wed Aug 21 04:12:17 CEST 2002


I'm using rotor to encrypt some files. When I open and decrypt the
files, they are being truncated. Not quite sure what's happening here,
but here's a code snip from the class I'm using:

class RotoTest:

    def __init__(self, filename, key):
        self.filename = os.path.abspath(filename)
        self.rot = rotor.newrotor(key, 20)

    def rotFile(self):
        print "Rotor file."
        fo = open(self.filename, "r")
        fn = open(self.filename + ".rot", "a")
        fn.write(self.rot.encrypt(fo.read()))
        fo.close()
        fn.close()

    def unrotFile(self):
        print "Unrotor file."
        fo = open(self.filename + ".rot", "r")
        fn = open(self.filename + ".unrot", "a")
        fn.write(self.rot.decrypt(fo.read()))
        fo.close()
        fn.close()

Here are the contents of the original vs. the unencrypted file:

<original>
This is just a test, 1.
This is just a test, 2.
This is just a test, 3.
This is just a test, 4.
This is just a test, 5.
This is just a test, 6.
This is just a test, 7.
This is just a test, 8.

Done!
</original>

<unencrypted>
This is just a test, 1.
This is just a test, 2.
This is just a test, 3.
This is just a test, 4.
This is just a 
</unencrypted>

Weird. Any ideas what's causing this?

-- 
Jeff Sykes
home.email - jeff at cowz.com 

"This does remind me of a good 
 friend who used to taunt me 
 whenever i said, 'PIN Number.' 
 In a very silly voice he would 
 say, 'Yes! Give me my PIN Number 
 so that i can go to the ATM 
 Machine and get some Cash Money!'"
  - Anon



More information about the Python-list mailing list