Skip to content

Instantly share code, notes, and snippets.

View liomoti's full-sized avatar

moti shaul liomoti

  • israel
View GitHub Profile
@gowhari
gowhari / vigenere-cipher.py
Created May 23, 2018 10:24
vigenere cipher
# encoding: utf8
# vigenere cipher
# https://stackoverflow.com/a/2490718/1675586
def encode(key, string):
encoded_chars = []
for i in range(len(string)):
key_c = key[i % len(key)]
encoded_c = chr(ord(string[i]) + ord(key_c) % 256)
encoded_chars.append(encoded_c)