Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 42 lines (32 sloc) 0.737 kB
11a9fa5 @Poincare Added everything
authored
1 from general import *
a515a55 Added caesar cipher.
Dhaivat Pandya authored
2
3 """pt: string to encrypt, plaintext
4 si: shift index"""
5 def encrypt(pt, si):
6 res = ""
7 for char in pt:
8 if char == " ":
9 res += " "
10 continue
11
12 res += itoc((ctoi(char)+si)%26)
13
14 return res
15
16 """et: encrypted string
17 si: shift index"""
18 def decrypt(et, si):
19 res = ""
20 for char in et:
21 if char == " ":
22 res += " "
23
24 res += itoc((ctoi(char)-si)%26)
25 return res
26
27 if __name__ == "__main__":
11a9fa5 @Poincare Added everything
authored
28 print "Note: Spaces are just ignored"
29
30 print "Enter something to encrypt: "
31 x = raw_input()
32 print "Enter shift: "
33 s = int(raw_input())
34 print "Encrypted: ", encrypt(x, s)
35
36 print "Enter something to decrypt: "
37 x = raw_input()
38 print "Enter shift: "
39 s = int(raw_input())
40 print "Decrypted: ", decrypt(x, s)
41
Something went wrong with that request. Please try again.