Skip to content

Commit 2ff601a

Browse files
committed
added functionalities
1 parent c3b892b commit 2ff601a

10 files changed

+59
-62
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Caesar-Cipher-Algorithm
2-
A Caesar Cipher algorithm for encrypting and decrypting text
2+
A Caesar Cipher encryption and decryption tool
-42 Bytes
Binary file not shown.
-15 Bytes
Binary file not shown.

__pycache__/extras.cpython-39.pyc

44 Bytes
Binary file not shown.
1.16 KB
Binary file not shown.

caesar_cipher.py

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
#Caeser Cipher Algorithm for Encryption and Decryption
1+
# Caeser Cipher Encryption and Decryption Tool
22

3-
from caesar_encryption import caesar_encryption, intro
4-
from caesar_decryption import caesar_decryption
5-
from extras import decor, load_a, load_b, load_c, load_d
3+
from extras import decor
64
import time
5+
from option_validator import options
76

87
@decor
98
def display():
@@ -16,43 +15,7 @@ def display():
1615
print("Hello there! What can i help you with?")
1716
time.sleep(1)
1817
print("\n1. Encryption")
19-
time.sleep(0.3)
2018
print("2. Decryption\n")
2119
time.sleep(1)
2220

23-
option = input("Input an option: ")
24-
25-
if option == '1':
26-
time.sleep(1.5)
27-
intro()
28-
print()
29-
time.sleep(1)
30-
plaintext = input("Enter the text: ")
31-
time.sleep(0.5)
32-
key = int(input("Enter the key: "))
33-
time.sleep(1)
34-
print("--------------------------")
35-
load_a()
36-
load_b()
37-
load_c()
38-
caesar_encryption(plaintext, key)
39-
40-
elif option == '2':
41-
time.sleep(1.5)
42-
intro()
43-
print()
44-
time.sleep(1)
45-
ciphertext = input("Enter the encrypted text: ")
46-
time.sleep(0.5)
47-
key = int(input("Enter the key:"))
48-
time.sleep(1)
49-
print("--------------------------")
50-
load_d()
51-
load_b()
52-
load_c()
53-
caesar_decryption(ciphertext, key)
54-
55-
else:
56-
time.sleep(1.5)
57-
print()
58-
print("invalid option")
21+
options()

caesar_decryption.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Decryption algorithm
1+
# Decryption algorithm
22
import time
3-
#import sys
43
from extras import decor
54

65
@decor
@@ -37,9 +36,4 @@ def caesar_decryption(ciphertext, key):
3736
decrypted_str = decrypted_str + i
3837

3938
time.sleep(1)
40-
print("The decrypted text is:", decrypted_str)
41-
42-
# for i in decrypted_str:
43-
# sys.stdout.write(i)
44-
# sys.stdout.flush()
45-
# time.sleep(0.2)
39+
print("The decrypted text is:", decrypted_str)

caesar_encryption.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#Encryption algorithm
1+
# Encryption algorithm
22
import time
3-
#import sys
43
from extras import decor
54

65
@decor
76
def intro():
7+
time.sleep(1)
88
print(" Welcome To Caesar Cipher Encryptor")
99

1010
def caesar_encryption(plaintext, key):
@@ -24,9 +24,4 @@ def caesar_encryption(plaintext, key):
2424
encrypted_str = encrypted_str + i
2525

2626
time.sleep(1)
27-
print("The encrypted text is:", encrypted_str)
28-
29-
# for i in encrypted_str:
30-
# sys.stdout.write(i)
31-
# sys.stdout.flush()
32-
# time.sleep(0.2)
27+
print("The encrypted text is:", encrypted_str)

extras.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def load_b():
2323
print()
2424

2525
def load_c():
26-
for k in 'Almost there....':
26+
print('Almost there!')
27+
for k in '..............':
2728
sys.stdout.write(k)
2829
sys.stdout.flush()
2930
time.sleep(0.3)

option_validator.py

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,51 @@
1-
def option_validator():
2-
pass
1+
import time
2+
import os
3+
from extras import load_a, load_b, load_c, load_d
4+
import caesar_encryption as ce
5+
import caesar_decryption as cd
36

47
def options():
5-
pass
8+
option = input("Input an option: ")
9+
print()
10+
if option == '1':
11+
time.sleep(1.5)
12+
os.system('cls')
13+
ce.intro()
14+
print()
15+
time.sleep(1)
16+
plaintext = input("Enter the text: ")
17+
time.sleep(0.5)
18+
key = int(input("Enter the key: "))
19+
print()
20+
time.sleep(1)
21+
print("--------------------------")
22+
load_a()
23+
load_b()
24+
load_c()
25+
ce.caesar_encryption(plaintext, key)
626

27+
elif option == '2':
28+
time.sleep(1.5)
29+
os.system('cls')
30+
cd.intro()
31+
print()
32+
time.sleep(1)
33+
ciphertext = input("Enter the encrypted text: ")
34+
time.sleep(0.5)
35+
key = int(input("Enter the key: "))
36+
print()
37+
time.sleep(1)
38+
print("--------------------------")
39+
load_d()
40+
load_b()
41+
load_c()
42+
cd.caesar_decryption(ciphertext, key)
743

44+
else:
45+
time.sleep(1.5)
46+
print("Invalid Option.")
47+
time.sleep(0.5)
48+
print("Try again!...")
49+
print()
50+
time.sleep(1)
51+
options()

0 commit comments

Comments
 (0)