0

It doesn't take much of a genius to recommend a compiled language, if you want to go for speed alone.

It is also quite evident that it is impractical to use only an interpreted language for this use, if the user is to encrypt files larger than 1mb. A test showed that it took 22 seconds to do something that could be done in less than a second for C.
We are all learning from this testing of program performance.

0

OK, fine. Go ahead and use this nice crypto, as it is easy to use for your files. But please crypt this small file attached with same password and function and save as tonyjv.txt.

Don't need to look it with text editor after crypting, just mail it to me :twisted:

(By the way sorry for poor mobile texting for that original quoted post, I corrected this quote)

Did not fall to that one, congratulation, you are really good with security.
Could you only send that powerpoint file which you emailed me last week encrypted with your password?

What is this program, you ask? Nothing important, just one small function I wrote.

def uncrypt(text, password):
    if len(text) != len(password):
        print 'Inputs must be same length'
    password = [ord(character) for character in password]
    text = [ord(character) ^ password[index] for (index, character) in enumerate(text)]
    
    return ''.join([chr(character_code) for character_code in text])


origfilename='text_100kb.txt'
cryptedfilename='text_100kb.xc'

print uncrypt(open(origfilename,'rb').read()[:512],open(cryptedfilename,'rb').read()[:512])

Edited by pyTony: slice from beginning to make faster

0

There should be return '' or raise error after line 3, for the if statement to have meaning.

def uncrypt(text, password):
    if len(text) != len(password):
        print 'Inputs must be same length'
        return ''
    password = [ord(character) for character in password]
    text = [ord(character) ^ password[index] for (index, character) in enumerate(text)]
    
    return ''.join([chr(character_code) for character_code in text])


origfilename='text_100kb.txt'
cryptedfilename='text_100kb.xc'

print uncrypt(open(origfilename,'rb').read()[:512],open(cryptedfilename,'rb').read()[:512])

Edited by pyTony: n/a

0

Hardly understand you guys, understand the functions and all but the modules, operator, and all, is this module operator used to perform logic operations on data, please reply, I'm new to python and I'm definitely new to the module called operator.

0

Original vegaseat's code used operator module, looks like. I think I can say confidently that my code is more relevant now a days.

Maybe old times it was necessary, now it is possible only to say

a_xor_b = a ^ b

Edited by pyTony: n/a

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.