mirror of
https://bitbucket.org/Mattrixwv/pypherstream.git
synced 2025-12-06 18:43:58 -05:00
99 lines
3.7 KiB
Python
99 lines
3.7 KiB
Python
#PypherStream/Playfair.py
|
|
#Matthew Ellison
|
|
# Created: 03-30-19
|
|
#Modified: 03-30-19
|
|
#This file contains the Playfair class for the PypherStream Project.
|
|
#This class takes input and uses a Playfair Cipher to encode or decode a message.
|
|
#This is a Python port of the CipherStream program found at https://bitbucket.org/Mattrixwv/CipherStream
|
|
|
|
|
|
class Playfair:
|
|
__replaced = "" #The letter that will need to be replaced in the grid and any input string or keyword
|
|
__replacer = "" #The letter that replaced __replaced in any input string or keyword
|
|
__doubled = "" #The letter that will be placed between double letters in the input string if necessary or to make the string length even
|
|
__version = "1.0" #The current library's version number
|
|
__grid: str = [["", "", "", "", ""],
|
|
["", "", "", "", ""],
|
|
["", "", "", "", ""],
|
|
["", "", "", "", ""],
|
|
["", "", "", "", ""]]
|
|
def __init__(self):
|
|
self.__inputString = "" #The message that needs to be encoded/decoded
|
|
self.__outputString = "" #The encoded/decoded message
|
|
self.__keyword = "" #The keyword used to create the grid
|
|
#Create the grid from the keyword
|
|
def __createGrid(self):
|
|
NotImplemented
|
|
#Returns true if the letter is found in the grid
|
|
def __checkGrid(self, letter: str) -> bool:
|
|
NotImplemented
|
|
#Searches the grid for letter and sets row & col to its location in grid
|
|
def __searchGrid(self, letter: str, row: int, col: int) -> int:
|
|
NotImplemented
|
|
#Strips invalid characters from the string that needs encoded/decoded
|
|
def __setInputString(self, input: str):
|
|
NotImplemented
|
|
#Strips invalid characters from the keyword and creates the grid
|
|
def __setKeyword(self, key: str):
|
|
NotImplemented
|
|
#Encodes inputString using the PLayfair cipher and stores the results in outputString
|
|
def __encode(self) -> str:
|
|
NotImplemented
|
|
#Decodes inputString using the PLayfair cipher and stores the results in outputString
|
|
def __decode(self) -> str:
|
|
NotImplemented
|
|
#Sets the keyword and inputString and encodes the message
|
|
def encode(self, keyword: str, input: str) -> str:
|
|
NotImplemented
|
|
#Sets the keyword and inputString and decodes the message
|
|
def decode(self, keyword: str, input: str) -> str:
|
|
NotImplemented
|
|
#Returns the keyword used to create the grid
|
|
def getKeyword(self) -> str:
|
|
NotImplemented
|
|
#Returns the string that needs encoded/decoded
|
|
def getInputString(self) -> str:
|
|
NotImplemented
|
|
#Returns the encoded/decoded message
|
|
def getOutputString(self) -> str:
|
|
NotImplemented
|
|
#Returns a string representation of the grid
|
|
def getGrid(self) -> str:
|
|
NotImplemented
|
|
#Makes sure all variables are empty
|
|
def reset(self):
|
|
NotImplemented
|
|
#Allow accessing and modifying of class variables
|
|
#Returns the character that needs replaced in messages and the grid
|
|
@classmethod
|
|
def getReplaced(cls) -> str:
|
|
NotImplemented
|
|
#Returns the character that replaces the character that needs replaced
|
|
@classmethod
|
|
def getReplacer(cls) -> str:
|
|
NotImplemented
|
|
#Returns the character that is added between 2 adjacent characters that are the same
|
|
@classmethod
|
|
def getDoubled(cls) -> str:
|
|
NotImplemented
|
|
#Sets the character that needs replaced in messages and the grid
|
|
@classmethod
|
|
def setReplaced(cls, replaced: str):
|
|
NotImplemented
|
|
#Sets the character that replaces the character that needs replaced
|
|
@classmethod
|
|
def setReplacer(cls, replacer: str):
|
|
NotImplemented
|
|
#Sets the character that is added betwee 2 adjacent characters that are the same
|
|
@classmethod
|
|
def setDoubled(cls, doubled: str):
|
|
NotImplemented
|
|
#Returns the current version of the library
|
|
@classmethod
|
|
def getVersion(cls) -> str:
|
|
NotImplemented
|
|
|
|
#This will run the appropriate commands if this script is called stand alone instead of with the rest of the PypherStream program
|
|
if __name__ == "__main__":
|
|
NotImplemented
|