mirror of
https://bitbucket.org/Mattrixwv/cipherstream.git
synced 2025-12-07 10:43:59 -05:00
51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
//Ciphers/Headers/Playfair.hpp
|
|
//Matthew Ellison
|
|
// Created: 4-25-18
|
|
//Modified: 4-25-18
|
|
//This file contains the declaration of the Playfair class
|
|
//It is designed to encrypt and decrypt strings using the Playfair cipher
|
|
|
|
|
|
#ifndef PLAYFAIR_HPP
|
|
#define PLAYFAIR_HPP
|
|
|
|
#include <string>
|
|
|
|
|
|
class Playfair{
|
|
private:
|
|
static char REPLACED; //The letter that will need to be replaced in the grid and any input string or keyword
|
|
static char REPLACER; //The letter that replaced REPLACED in any input string or keyword
|
|
static char DOUBLED; //The letter that will be placed between double letters in the input string if necessary or to make the string length even
|
|
std::string inputString;
|
|
std::string outputString;
|
|
std::string keyword;
|
|
char grid[5][5];
|
|
void createGrid();
|
|
bool checkGrid(const char letter) const;
|
|
void searchGrid(char letter, int& row, int& col);
|
|
public:
|
|
Playfair();
|
|
~Playfair();
|
|
void reset();
|
|
std::string encode();
|
|
std::string encode(std::string keyword, std::string input);
|
|
std::string decode();
|
|
std::string decode(std::string keyword, std::string input);
|
|
void setKeyword(std::string key);
|
|
std::string getKeyword() const;
|
|
void setInputString(std::string input);
|
|
std::string getInputString() const;
|
|
std::string getOutputString() const;
|
|
std::string getGrid() const;
|
|
//Change static variables
|
|
static char getReplaced();
|
|
static void setReplaced(const char replaced);
|
|
static char getReplacer();
|
|
static void setReplacer(const char replacer);
|
|
static char getDoubled();
|
|
static void setDoubled(const char doubled);
|
|
};
|
|
|
|
#endif //PLAYFAIR_HPP
|