Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ok(x):
- if 65 <= x <= 90:
- x = x - 65
- return(x)
- elif 97<= x <=122:
- x = x - 97
- return(x)
- i = 0
- sh = '\0'
- while True:
- print(' шифратор-1\n дешифратор-2')
- q=int(input('commad'))
- if q==1:
- text = input('text')
- key = input('key')
- while i < len(text):
- a = ord(text[i])
- k = ord(key[i%len(key)])
- if 65 <= a <= 90:
- a = a - 65 + ok(k)
- if a>25:
- a = a - 26
- a = a + 65
- elif 97<= a <=122:
- a = a - 97 + ok(k)
- if a>25:
- a = a - 26
- a = a + 97
- sh = sh + chr(a)
- i+=1
- print ('\n \n' + sh)
- elif q==2:
- text = input('text')
- key = input('key')
- while i < len(text):
- a = ord(text[i])
- k = ord(key[i%len(key)])
- if 65 <= a <= 90:
- a = a - 65 - ok(k)
- if 0>a:
- a = a + 26
- a = a + 65
- elif 97<= a <=122:
- a = a - 97 - ok(k)
- if 0>a:
- a = a + 26
- a = a + 97
- sh = sh + chr(a)
- i+=1
- print ('\n \n' + sh)
- else:
- print('this command not exist')
Add Comment
Please, Sign In to add comment