Skip to content

Instantly share code, notes, and snippets.

Avatar

Raihan dssstr

View GitHub Profile
@dssstr
dssstr / vigenere.py
Last active Jul 23, 2021
Simple Vigenere Cipher written in Python 3.5.
View vigenere.py
def encrypt(plaintext, key):
key_length = len(key)
key_as_int = [ord(i) for i in key]
plaintext_int = [ord(i) for i in plaintext]
ciphertext = ''
for i in range(len(plaintext_int)):
value = (plaintext_int[i] + key_as_int[i % key_length]) % 26
ciphertext += chr(value + 65)
return ciphertext