Skip to content

Commit eca5f5e

Browse files
authored
Update Substitution Cipher.py
1 parent 0ce6ef7 commit eca5f5e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Substitution Cipher/Substitution Cipher.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def sc_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 sc_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:

0 commit comments

Comments
 (0)