-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcesar.py
More file actions
21 lines (18 loc) · 774 Bytes
/
cesar.py
File metadata and controls
21 lines (18 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def crypt(plainStr, shiftInt):
resultStr = ""
for char in plainStr:
if ord(char) + shiftInt > ord('z'):
resultStr = resultStr + chr(ord(char) + shiftInt - 26)
else:
resultStr = resultStr + chr(ord(char) + shiftInt)
print('crypt:' + resultStr)
def decrypt(cryptoStr, shiftInt):
resultStr = ""
for char in cryptoStr:
if ord(char) - shiftInt < ord('a'):
resultStr = resultStr + chr(ord(char) - shiftInt + 26)
else:
resultStr = resultStr + chr(ord(char) - shiftInt)
print('decrypt:' + resultStr)
crypt("Zyeb myxdsxeob sv do pkenbk kxkvicob vo psmrsob nsczyxslvo sms ",10)
decrypt("Zyeb myxdsxeob sv do pkenbk kxkvicob vo psmrsob nsczyxslvo sms ",10)