forked from ponix4k/pycryptr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rot.py
executable file
·32 lines (26 loc) · 969 Bytes
/
Rot.py
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
#!/usr/bin/python3
#This is a simple Rotatonal Encoder/Decoder that will shift letters around based on the value given
#CharTypes
Alpha_Low = ('abcdefghijklmnopqrstuvwxyz') #set up array of lowercase characters
Alpha_Up = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ') #set up array of uppercase characters
#Message
newMessage = ''
message = input('Please enter a message to encode/decode: ') #request message from user
Rot = input('Please Enter Rotation (0 for all) : ') #request rotation amount e.g rot 2 a = c
RotVal = int(Rot)
#Lowercase Search
for Char in message:
if Char in Alpha_Low:
position = Alpha_Low.find(Char)
newPosition = (position + RotVal) % 26
newChar = Alpha_Low[newPosition]
newMessage += newChar
#Uppercase Search
elif Char in Alpha_Up:
position = Alpha_Up.find(Char)
newPosition = (position + RotVal) % 26
newChar = Alpha_Up[newPosition]
newMessage += newChar
else:
newMessage += Char
print('Encoded/Decoded message is: ',newMessage)