[Solved] How to ‘encrypt’ a file


If your goal is just to exchange the letters in a string with others that you specify, then the solution is the following:

decrypted = 'abcdefghijklmnopqrstuvwxyz' #normal alphabet
encrypted = 'MNBVCXZLKJHGFDSAPOIUYTREWQ' #your "crypted" alphabet

#Encription
text="cryptme" #the string to be crypted
encrypted_text=""
for letter in text:
    encrypted_text += encrypted[decrypted.find(letter)]
print encrypted_text
#will print BOWAUFC

#Decription
text = encrypted_text #"BOWAUFC" in this example
decrypted_text=""
for letter in text:
    decrypted_text += decrypted[encrypted.find(letter)]
print decrypted_text
#will print cryptme

Note that your “crypted alphabet” do not convert any white space or any symbols but the lowercase letters, if you have other symbols in your text you have to include them as well.

However, this is not the proper way to encrypt anything! As suggested by others already, look up for a proper encryption algorithm.

3

solved How to ‘encrypt’ a file