Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added everything

  • Loading branch information...
commit 11a9fa5bab106c690dddafdda7d24457b3028e9a 1 parent a515a55
@Poincare authored
View
1  __init__.py
@@ -0,0 +1 @@
+##
View
23 caesar.py
@@ -1,9 +1,4 @@
-"""Encrypts and Decrypts using the Caesar Cipher. License: Tell me if you ever use it, but, if you don't its okay, I don't really care."""
-def ctoi(c):
- return (ord(c.upper())-64)
-
-def itoc(v):
- return (chr(v+64))
+from general import *
"""pt: string to encrypt, plaintext
si: shift index"""
@@ -30,5 +25,17 @@ def decrypt(et, si):
return res
if __name__ == "__main__":
- print encrypt("I am awesome", 15)
- print decrypt("ydc", 15)
+ print "Note: Spaces are just ignored"
+
+ print "Enter something to encrypt: "
+ x = raw_input()
+ print "Enter shift: "
+ s = int(raw_input())
+ print "Encrypted: ", encrypt(x, s)
+
+ print "Enter something to decrypt: "
+ x = raw_input()
+ print "Enter shift: "
+ s = int(raw_input())
+ print "Decrypted: ", decrypt(x, s)
+
View
7 general.py
@@ -0,0 +1,7 @@
+def ctoi(c):
+ return (ord(c.upper())-64)
+
+def itoc(v):
+ return (chr(v+64))
+
+
View
BIN  general.pyc
Binary file not shown
View
25 vigenere.py
@@ -0,0 +1,25 @@
+from general import *
+
+def equateLen(x, passphr):
+ sameLength = False
+ pp = ""
+ while not sameLength:
+ for c in passphr:
+ pp = pp+c
+ if len(pp) == len(pp):
+ sameLength = True
+ break
+
+ return pp
+
+def encrypt(x, passphr):
+ pp = equateLen(x, passphr)
+
+ res = ""
+ for i in range(0, len(pp)):
+ res += itoc(ctoi(pp[i])+ctoi(x[i]))
+
+ return res
+
+print encrypt("ATTACK", "ABC")
+
Please sign in to comment.
Something went wrong with that request. Please try again.