Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
named group solution in Clear category for Vigenere Cipher by gyahun_dash
import itertools as it, operator as op, re, string
def subchr(text1, text2, alphabet=string.ascii_uppercase):
seq1, seq2 = [map(alphabet.index, t) for t in (text1, text2)]
return ''.join(alphabet[i] for i in map(op.sub, seq1, it.cycle(seq2)))
def decode_vigenere(old_decrypted, old_encrypted, new_encrypted):
keyword = subchr(old_encrypted, old_decrypted)
match = re.match(r'(?P.+)(?P=repeat)|(?P.+)', keyword)
return subchr(new_encrypted, match.group('repeat') or match.group('whole'))
Nov. 6, 2014
Comments: