Created
January 18, 2015 23:44
-
-
Save Browne/bd0771bb032e5fb96b96 to your computer and use it in GitHub Desktop.
Vigenere with a known key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| def crack(x, y): | |
| """For the length of string i, get the value of the character A=1, B=2 etc | |
| Subtract this from the value of the code at the relevant position | |
| Modulo 26 to remove an remainders/negatives.""" | |
| result = "" | |
| for i in range(len(x)): | |
| result += chr((((ord(x[i].lower())) - (ord(y[i % 21].lower()))) % 26) + 97).upper() | |
| return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment