-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43c888d
commit 2144b8a
Showing
6 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
def caesarEncrypt(text, shift): | ||
result = [] | ||
|
||
for char in text: | ||
# Check if the character is an uppercase letter | ||
if 'A' <= char <= 'Z': | ||
# Rotate the character by 13 within the uppercase letters | ||
result.append(chr((ord(char) - ord('A') + shift) % 26 + ord('A'))) | ||
|
||
# Check if the character is a lowercase letter | ||
elif 'a' <= char <= 'z': | ||
# Rotate the character by 13 within the lowercase letters | ||
result.append(chr((ord(char) - ord('a') + shift) % 26 + ord('a'))) | ||
|
||
else: | ||
# If it's not a letter, keep it unchanged | ||
result.append(char) | ||
|
||
return ''.join(result) | ||
|
||
def caesarDecrypt(text, shift): | ||
result = [] | ||
|
||
for char in text: | ||
# Check if the character is an uppercase letter | ||
if 'A' <= char <= 'Z': | ||
# Rotate the character by 13 within the uppercase letters | ||
result.append(chr((ord(char) - ord('A') - shift) % 26 + ord('A'))) | ||
|
||
# Check if the character is a lowercase letter | ||
elif 'a' <= char <= 'z': | ||
# Rotate the character by 13 within the lowercase letters | ||
result.append(chr((ord(char) - ord('a') - shift) % 26 + ord('a'))) | ||
|
||
else: | ||
# If it's not a letter, keep it unchanged | ||
result.append(char) | ||
|
||
return ''.join(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/__pycache__ | ||
/__pycache__/* | ||
__pycache__/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters