Navigation Menu

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 December 16, 2023 09:01
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