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
|
||||
//Matthew Ellison
|
||||
// Created: 4-29-18
|
||||
//Modified; 4-29-18
|
||||
//Modified; 5-5-18
|
||||
//This file contains the implementation of the Vigenere class
|
||||
|
||||
#include "../Headers/Vigenere.hpp"
|
||||
@@ -10,12 +10,26 @@
|
||||
#include <cctype>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Construct a new Vigenere object
|
||||
*
|
||||
*/
|
||||
Vigenere::Vigenere(){
|
||||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destroy the Vigenere object
|
||||
*
|
||||
*/
|
||||
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){
|
||||
//Make sure inputString is clear
|
||||
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{
|
||||
return inputString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the encoded/decoded message
|
||||
*
|
||||
* @return The encoded/decoded message
|
||||
*/
|
||||
std::string Vigenere::getOutputString() const{
|
||||
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){
|
||||
//Make sure the keyword is blank
|
||||
keyword = "";
|
||||
@@ -58,10 +87,19 @@ void Vigenere::setKeyword(std::string key){
|
||||
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{
|
||||
return keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Uses keyword to set the offsets of the letters used during encoding/decoding
|
||||
*
|
||||
*/
|
||||
void Vigenere::setOffset(){
|
||||
//Make sure offset is empty
|
||||
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{
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encodes the inputString using the Vigenere cipher and saves the result in outputString
|
||||
*
|
||||
* @return The encoded message
|
||||
*/
|
||||
std::string Vigenere::encode(){
|
||||
//Clear the outputString
|
||||
outputString = "";
|
||||
@@ -100,12 +149,24 @@ std::string Vigenere::encode(){
|
||||
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){
|
||||
setKeyword(key);
|
||||
setInputString(input);
|
||||
return encode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decodes the inputString using the Vigenere cipher and saves the result in outputString
|
||||
*
|
||||
* @return The decoded message
|
||||
*/
|
||||
std::string Vigenere::decode(){
|
||||
//Clear the outputString
|
||||
outputString = "";
|
||||
@@ -127,12 +188,23 @@ std::string Vigenere::decode(){
|
||||
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){
|
||||
setKeyword(key);
|
||||
setInputString(input);
|
||||
return decode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Makes sure all of the variables are empty
|
||||
*
|
||||
*/
|
||||
void Vigenere::reset(){
|
||||
inputString = outputString = keyword = "";
|
||||
offset.clear();
|
||||
|
||||
Reference in New Issue
Block a user