forked from aiti-ghana-2012/Lab_Python_03
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcipher.py
More file actions
28 lines (26 loc) · 694 Bytes
/
Copy pathcipher.py
File metadata and controls
28 lines (26 loc) · 694 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
"""
letter = 'a'
# converts a letter to ascii code
ascii_code = ord(letter)
# convers ascii code to a letter
letter_res = chr(ascii_code)
print ascii_code, letter_res
"""
phrase= raw_input('Enter a phrase to encrypt: ')
shift= input('Enter shift value: ')
encString=''
for c in phrase:
print 'c is ' + c
if ord(c)>=65 and ord(c)<=90:
temp=ord(c)-65
temp= (temp + shift) % 26
temp=temp+65
encString=encString+chr(temp)
elif ord(c)>=97 and ord(c)<=122:
temp=ord(c)-97
temp= (temp + shift) % 26
temp=temp+97
encString=encString+chr(temp)
else:
encString=encString+c
print 'Encryption ' + encString