I have just started looking at simple cryptography in order to learn python better. Encryptions and decryptions should be speedy and accurate so im hoping it will improve my programming skills.
I recently wrote this quick script for a shift cypher but i wasnt sure how to be able to define the shift.
import string m = string.maketrans('abcdefghijklmnopqrstuvwxyz', 'pqrstuvwxyzabcdefghijklmno') a = 'this should have been fairly easy to crack considering the length of the message' n = string.maketrans('pqrstuvwxyzabcdefghijklmno', 'abcdefghijklmnopqrstuvwxyz') x = string.translate(a, m) print x y = string.translate(x, n) print y
for example if i shifter the letter a over 4 times it would be the letter e. I could make 26 encryption variables and 26 decryption variables but this isnt really pythonic or efficient. can anyone point me in the right direction?
Thanks for your time.