Created
November 1, 2018 20:22
-
-
Save DanteAlabastro/f38f9081822bc413abe64a1ec6405cd0 to your computer and use it in GitHub Desktop.
A Python creation of the de Vigenére cipher
This file contains 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
letter = 'a' | |
n = 1 | |
# input - strip white space and punctuation. all lowercase. | |
# key | |
key = 'test' | |
# key as list | |
keyL = list(key) | |
# key fit text len | |
key_fit = 1 | |
# Text | |
text = 'hello' | |
# Encrypted 'Character + int = chr(ord(a)+n)' | |
encrypted = [chr(ord(i) + ord('s') - 90) for i in list(text)] | |
# Return | |
print(text) | |
print(''.join(encrypted)) | |
# ''' | |
# >>> a = ord('a') - 96 | |
# >>> b = a + a | |
# >>> c = chr(b + 96) | |
# >>> print(c) | |
# ''' | |
# Add two characters | |
def c(a, b): | |
d = (ord(a) - 96) + (ord(b) - 96) | |
if d > 26: | |
# Subtract 26 and add 96 | |
print(chr(d + 70)) | |
else: | |
print(chr(d + 96)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment