Skip to content

Commit 524bcff

Browse files
authored
Update Ceaser Cipher.py
1 parent 323b678 commit 524bcff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Ceaser Cipher/Ceaser Cipher.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def cc_encryption(st, shift):
88
if i == " ":
99
res = res + space_substitute[random.randint(0, 9)]
1010
elif 48 <= ord(i) <= 57:
11-
res = res + chr((ord(i) + shift - 48) + 48)
11+
res = res + chr((ord(i) + shift - 48) %10 + 48)
1212
elif i.isupper():
1313
res = res + chr((ord(i) + shift - 65) % 26 + 65)
1414
else:
@@ -23,7 +23,7 @@ def cc_decryption(st, shift):
2323
if i in space_substitute:
2424
res = res + " "
2525
elif 48 <= ord(i) <= 57:
26-
res = res + chr((ord(i) - shift - 48) + 48)
26+
res = res + chr((ord(i) - shift - 48) % 10 + 48)
2727
elif i.isupper():
2828
res = res + chr((ord(i) - shift - 65) % 26 + 65)
2929
else:
@@ -37,4 +37,4 @@ def cc_decryption(st, shift):
3737
decrypted = cc_decryption(encrypted, move)
3838
print("Original text: " + string)
3939
print("Encrypted text: " + encrypted)
40-
print("Decrypted text: " + decrypted)
40+
print("Decrypted text: " + decrypted)

0 commit comments

Comments
 (0)