mirror of
https://bitbucket.org/Mattrixwv/cipherstream.git
synced 2025-12-06 18:33:58 -05:00
Added documentation
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
//Ciphers/SourceFiles/Vigenere.cpp
|
//Ciphers/SourceFiles/Vigenere.cpp
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 4-29-18
|
// Created: 4-29-18
|
||||||
//Modified; 4-29-18
|
//Modified; 5-5-18
|
||||||
//This file contains the implementation of the Vigenere class
|
//This file contains the implementation of the Vigenere class
|
||||||
|
|
||||||
#include "../Headers/Vigenere.hpp"
|
#include "../Headers/Vigenere.hpp"
|
||||||
@@ -10,12 +10,26 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Vigenere object
|
||||||
|
*
|
||||||
|
*/
|
||||||
Vigenere::Vigenere(){
|
Vigenere::Vigenere(){
|
||||||
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destroy the Vigenere object
|
||||||
|
*
|
||||||
|
*/
|
||||||
Vigenere::~Vigenere(){
|
Vigenere::~Vigenere(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Removes all invalid characters from input and sets it to inputString
|
||||||
|
*
|
||||||
|
* @param input The string you want to encode/decode
|
||||||
|
*/
|
||||||
void Vigenere::setInputString(std::string input){
|
void Vigenere::setInputString(std::string input){
|
||||||
//Make sure inputString is clear
|
//Make sure inputString is clear
|
||||||
inputString = "";
|
inputString = "";
|
||||||
@@ -33,14 +47,29 @@ void Vigenere::setInputString(std::string input){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the string you wish to encode/decode
|
||||||
|
*
|
||||||
|
* @return The string you wish to encode/decode
|
||||||
|
*/
|
||||||
std::string Vigenere::getInputString() const{
|
std::string Vigenere::getInputString() const{
|
||||||
return inputString;
|
return inputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the encoded/decoded message
|
||||||
|
*
|
||||||
|
* @return The encoded/decoded message
|
||||||
|
*/
|
||||||
std::string Vigenere::getOutputString() const{
|
std::string Vigenere::getOutputString() const{
|
||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Removes all invalid characters from key and sets it to keyword
|
||||||
|
*
|
||||||
|
* @param key The keyword used for the cipher
|
||||||
|
*/
|
||||||
void Vigenere::setKeyword(std::string key){
|
void Vigenere::setKeyword(std::string key){
|
||||||
//Make sure the keyword is blank
|
//Make sure the keyword is blank
|
||||||
keyword = "";
|
keyword = "";
|
||||||
@@ -58,10 +87,19 @@ void Vigenere::setKeyword(std::string key){
|
|||||||
setOffset();
|
setOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the keyword you are using for the cipher
|
||||||
|
*
|
||||||
|
* @return The keyword you are using for the cipher
|
||||||
|
*/
|
||||||
std::string Vigenere::getKeyword() const{
|
std::string Vigenere::getKeyword() const{
|
||||||
return keyword;
|
return keyword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uses keyword to set the offsets of the letters used during encoding/decoding
|
||||||
|
*
|
||||||
|
*/
|
||||||
void Vigenere::setOffset(){
|
void Vigenere::setOffset(){
|
||||||
//Make sure offset is empty
|
//Make sure offset is empty
|
||||||
offset.clear();
|
offset.clear();
|
||||||
@@ -74,10 +112,21 @@ void Vigenere::setOffset(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the vector that holds the offsets of the letters used during encoding/decoding
|
||||||
|
*
|
||||||
|
* @return A the vector holding offsets of the letters used during encoding/decoding
|
||||||
|
* @note Used mostly for debuging
|
||||||
|
*/
|
||||||
std::vector<unsigned int> Vigenere::getOffsets() const{
|
std::vector<unsigned int> Vigenere::getOffsets() const{
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Encodes the inputString using the Vigenere cipher and saves the result in outputString
|
||||||
|
*
|
||||||
|
* @return The encoded message
|
||||||
|
*/
|
||||||
std::string Vigenere::encode(){
|
std::string Vigenere::encode(){
|
||||||
//Clear the outputString
|
//Clear the outputString
|
||||||
outputString = "";
|
outputString = "";
|
||||||
@@ -100,12 +149,24 @@ std::string Vigenere::encode(){
|
|||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets all of the variables for the cipher and returns the result
|
||||||
|
*
|
||||||
|
* @param key The keyword used in the cipher
|
||||||
|
* @param input The message that you wish to encode
|
||||||
|
* @return The encoded message
|
||||||
|
*/
|
||||||
std::string Vigenere::encode(std::string key, std::string input){
|
std::string Vigenere::encode(std::string key, std::string input){
|
||||||
setKeyword(key);
|
setKeyword(key);
|
||||||
setInputString(input);
|
setInputString(input);
|
||||||
return encode();
|
return encode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Decodes the inputString using the Vigenere cipher and saves the result in outputString
|
||||||
|
*
|
||||||
|
* @return The decoded message
|
||||||
|
*/
|
||||||
std::string Vigenere::decode(){
|
std::string Vigenere::decode(){
|
||||||
//Clear the outputString
|
//Clear the outputString
|
||||||
outputString = "";
|
outputString = "";
|
||||||
@@ -127,12 +188,23 @@ std::string Vigenere::decode(){
|
|||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets all of the variables for the cipher and returns the result
|
||||||
|
*
|
||||||
|
* @param key The keyword used in the cipher
|
||||||
|
* @param input The message that you wish to decode
|
||||||
|
* @return The decoded message
|
||||||
|
*/
|
||||||
std::string Vigenere::decode(std::string key, std::string input){
|
std::string Vigenere::decode(std::string key, std::string input){
|
||||||
setKeyword(key);
|
setKeyword(key);
|
||||||
setInputString(input);
|
setInputString(input);
|
||||||
return decode();
|
return decode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Makes sure all of the variables are empty
|
||||||
|
*
|
||||||
|
*/
|
||||||
void Vigenere::reset(){
|
void Vigenere::reset(){
|
||||||
inputString = outputString = keyword = "";
|
inputString = outputString = keyword = "";
|
||||||
offset.clear();
|
offset.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user