Reputation: 1593
I'm trying to make my programs for the public (freeware) and I just want to know the code for making a file encrypted. (Python language 2.7.3)
Upvotes: 1
Views: 3291
Reputation: 4837
here what you need
def encoder(path,pwd,topath):
"""
@path: file path you wish to encrypt including filename
@pwd: seek value 'you should remember that if you want to decrypt it'
@topath: file path for encrypted file included filename
"""
k = long(pwd) # key # password in int
f1 = open( path, "rb") # file path you wish to encrypt
bytearr = map (ord, f1.read() )
f1.close()
f2 = open( topath, "wb" ) # path for encrypt file to write
random.seed(k)
for i in range(len(bytearr)):
byt = (bytearr[i] + random.randint(0, 255)) % 256
f2.write(chr(byt))
f2.close()
Have you tried to search google for it, or even stackoverflow.
Upvotes: 3