-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrot_cipher.py
More file actions
45 lines (23 loc) · 954 Bytes
/
rot_cipher.py
File metadata and controls
45 lines (23 loc) · 954 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
37
38
39
40
41
from dataclasses import replace
import string
string_ascii_list = list(string.ascii_lowercase)
#print(string_ascii_list)
# 1) Prompts the user for a string
prompt = input("Enter letters: ")
prompt = prompt.replace(" ", "") # remove spaces if any
# Allow the user to input the amount of rotation used in the encryption. (ROTN)
user_rotn_input = int(input("input number of rotation: "))
prompt_list = list(prompt) # convert to list of string
# 2) Encodes it with ROT13
for char in prompt_list:
output =[]
output += [string_ascii_list.index(char)]
for num in output:
# print(num)
# 3) For each character, find the corresponding character, add it to an output string
if num + user_rotn_input < 26:
print(string_ascii_list[num + user_rotn_input], end="\n")
if num + user_rotn_input > 26:
print(string_ascii_list[num + user_rotn_input - 26], end="\n")
# Version 2:
##