Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my_alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- def rotate(x , y):
- z = my_alp.find(x)
- if ((z + y) > 25):
- w = (z + y) % 26
- return my_alp(w)
- return my_alp(z + y)
- def cencrypt(x , y):
- x = x.upper()
- if len(x) == 1:
- return rotate(x , y)
- def c_encrypt(x , y):
- x = x.upper()
- c= cencrypt(x , y)
- return c
- def cdecrypt(string , key):
- string = string.upper()
- if len(string) == 1:
- return rotate(string , key * -1)
- def c_decrypt(string , key):
- string = string.upper()
- new_string = cdecrypt(string , key * -1)
- return new_string
- def vig_rotate(x , y):
- first_index = my_alp.find(x.upper())
- last_index = (first_index +y) % 26
- return(my_alp(last_index))
- def vig_encrypt(x , y):
- encryption = ''
- for character in x:
- if character.isalpha():
- encryption += vig_rotate(character , y)
- else:
- encryption += character
- return(encryption)
- def vig_decrypt(x , y):
- encryption = ''
- for character in x:
- if character.isalpha():
- encryption += vig_rotate(character , y * -1)
- else:
- encryption += character
- return encryption
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement