Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ENCRYPTOR TEST"""
- def key():
- a = True
- inp = int(raw_input("please enter a key: "))
- if inp <= 35:
- return inp
- else:
- while a == True:
- inp = int(raw_input("please enter a key: "))
- if inp <= 35:
- a = False
- return inp
- def encrypt(eord):
- output = ""
- alphabet = ["7","a","0","b","c","5","d","e","6","f","g","1","h","i","j","k","8","l","3","m","n","2","o","p","q","9","r","4","s","t","u","v","w","x","y","z"]
- inp = raw_input("What phrase would you like to Change?: ")
- key1 = key()
- phrase = inp.split()
- for i in phrase:
- i = i.lower()
- splitword = list(i)
- for a in range(len(splitword)):
- for c in range(35):
- if splitword[a] == alphabet[c]:
- if eord == 1: #if you chose to encrypt
- letter = c + key1 #the new position is created by adding the key to the position of the letter in the alphabet
- elif eord == 0: # if you chose to decrypt
- letter = c - key1 # the actual position of the letter is determined
- #out of bounds checks
- if letter > 35:
- letter = letter - 35
- elif letter < 0:
- letter = 35 + letter
- output += str(alphabet[letter]) #appends newly generated encryption/decryption to the overall output
- print output # does what it says on the tin
- print("Welcome to encryption service v0.1")
- resp1= raw_input("Would you like to encrypt or decrypt: ")
- resp1 = resp1.lower()
- if resp1 == "encrypt" or resp1 == "e":
- encrypt(1)
- elif resp1 == "decrypt" or resp1 == "d":
- encrypt(0)
Advertisement
Add Comment
Please, Sign In to add comment