ke1dan

Untitled

Jul 7th, 2020
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. #На тесте "it's a shift cipher!" выдает x t ' k , хотя "xt'k o v" should equal "xt'k o vwixl qzswej!"
  2.  
  3. class Vigenere(object):
  4.  
  5.     def __init__(self,key,alp):
  6.         self.key = key
  7.         self.alp = alp
  8.  
  9.     def encode(self,text):
  10.         if text.lower() == text:
  11.             r = []
  12.             alphabet = self.alp*2
  13.             print(alphabet)
  14.             for i,j in zip(self.key,text):
  15.                 if j not in self.alp:
  16.                     r += j
  17.                 else:
  18.                     r += alphabet[self.alp.index(i)+self.alp.index(j)]
  19.             return r
  20.         return text
Advertisement
Add Comment
Please, Sign In to add comment