-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcc_encrypt.py
More file actions
36 lines (27 loc) · 1019 Bytes
/
cc_encrypt.py
File metadata and controls
36 lines (27 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import string
from time import sleep
alphabet = string.ascii_lowercase # "abcdefghijklmnopqrstuvwxyz"
def encryptWithParams(message, key):
encrypted_message = ""
for c in message:
if c in alphabet:
position = alphabet.find(c)
new_position = (position + key) % 26
new_character = alphabet[new_position]
encrypted_message += new_character
else:
encrypted_message += c
return encrypted_message
def encrypt():
print("Welcome to Caesar Cipher Encryption.\n")
message1 = input("Type a message you would like to encrypt: ").lower()
print()
key1 = int(input("Enter your cypher step: "))
encrypted_message = encryptWithParams(message1,key1)
print("\nEncrypting your message...\n")
sleep(2) # give an appearance of doing something complicated
print("Stand by, almost finished...\n")
sleep(2) # more of the same
print("Your encrypted message is:\n")
print(encrypted_message)
encrypt()