Skip to content

Instantly share code, notes, and snippets.

View dssstr's full-sized avatar

Raihan dssstr

View GitHub Profile
@dssstr
dssstr / vigenere.py
Last active August 18, 2024 00:10
Simple Vigenere Cipher written in Python 3.5.
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