Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class VernamSolver:
- dictionary = None
- def __init__(self, dictionary:str):
- self.dictionary = dictionary
- def __vernamAlgorithm(self, text:str, key:str) -> str:
- result = ""
- for i in range(len(text)):
- result += self.dictionary[self.dictionary.find(key[i % len(key)]) ^ self.dictionary.find(text[i])]
- return result
- def encode(self, text:str, key:str) -> str:
- return self.__vernamAlgorithm(text, key)
- def decode(self, cypher:str, key:str) -> str:
- return self.__vernamAlgorithm(cypher, key)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement