mirror of
https://bitbucket.org/Mattrixwv/cipherstream.git
synced 2025-12-06 18:33:58 -05:00
Added new documentation
This commit is contained in:
@@ -11,34 +11,72 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Caesar:: Caesar object
|
||||||
|
*
|
||||||
|
*/
|
||||||
Caesar::Caesar(){
|
Caesar::Caesar(){
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destroy the Caesar:: Caesar object
|
||||||
|
*
|
||||||
|
*/
|
||||||
Caesar::~Caesar(){
|
Caesar::~Caesar(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the current inputString
|
||||||
|
*
|
||||||
|
* @param input The string that you wish to encode
|
||||||
|
*/
|
||||||
void Caesar::setInputString(std::string input){
|
void Caesar::setInputString(std::string input){
|
||||||
inputString = input;
|
inputString = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the current inputString
|
||||||
|
*
|
||||||
|
* @return The message that was just encoded/decoded
|
||||||
|
*/
|
||||||
std::string Caesar::getInputString() const{
|
std::string Caesar::getInputString() const{
|
||||||
return inputString;
|
return inputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set shift to a valid integer
|
||||||
|
*
|
||||||
|
* @param shiftAmount The number of letters the cipher needs to be shifted
|
||||||
|
*/
|
||||||
void Caesar::setShift(int shiftAmount){
|
void Caesar::setShift(int shiftAmount){
|
||||||
//If you shift more than 26 you will just be wrapping back around again
|
//If you shift more than 26 you will just be wrapping back around again
|
||||||
shift = shiftAmount % 26;
|
shift = shiftAmount % 26;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the current number of letters the cipher is set to shift
|
||||||
|
*
|
||||||
|
* @return The current number of letters the cipher is currently set to shift
|
||||||
|
*/
|
||||||
int Caesar::getShift() const{
|
int Caesar::getShift() const{
|
||||||
return shift;
|
return shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the last message encoded/decoded
|
||||||
|
*
|
||||||
|
* @return The messge that was just encoded/decoded
|
||||||
|
*/
|
||||||
std::string Caesar::getOutputString() const{
|
std::string Caesar::getOutputString() const{
|
||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Encodes a message using the Caesar cipher
|
||||||
|
*
|
||||||
|
* @return The encoded message (outputString)
|
||||||
|
*/
|
||||||
std::string Caesar::encode(){
|
std::string Caesar::encode(){
|
||||||
char temp; //A temperary holder for the current working character
|
char temp; //A temperary holder for the current working character
|
||||||
for(int cnt = 0;cnt < inputString.size();++cnt){
|
for(int cnt = 0;cnt < inputString.size();++cnt){
|
||||||
@@ -72,12 +110,24 @@ std::string Caesar::encode(){
|
|||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Encodes a message using the Caesar cipher
|
||||||
|
*
|
||||||
|
* @param shiftAmount The number of letters you need to shift for the cipher
|
||||||
|
* @param input The message that needs encoded
|
||||||
|
* @return The encoded message
|
||||||
|
*/
|
||||||
std::string Caesar::encode(int shiftAmount, std::string input){
|
std::string Caesar::encode(int shiftAmount, std::string input){
|
||||||
setShift(shiftAmount);
|
setShift(shiftAmount);
|
||||||
setInputString(input);
|
setInputString(input);
|
||||||
return encode();
|
return encode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Decodes a message using the Caesar cipher
|
||||||
|
*
|
||||||
|
* @return The decoded message (outputString)
|
||||||
|
*/
|
||||||
std::string Caesar::decode(){
|
std::string Caesar::decode(){
|
||||||
char temp;
|
char temp;
|
||||||
for(int cnt = 0;cnt < inputString.size();++cnt){
|
for(int cnt = 0;cnt < inputString.size();++cnt){
|
||||||
@@ -109,12 +159,23 @@ std::string Caesar::decode(){
|
|||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Decodes a message using the Caesar cipher
|
||||||
|
*
|
||||||
|
* @param shiftAmount The number of letters you need to shift for the cipher
|
||||||
|
* @param input The message that needs decoded
|
||||||
|
* @return The decoded message
|
||||||
|
*/
|
||||||
std::string Caesar::decode(int shiftAmount, std::string input){
|
std::string Caesar::decode(int shiftAmount, std::string input){
|
||||||
setShift(shiftAmount);
|
setShift(shiftAmount);
|
||||||
setInputString(input);
|
setInputString(input);
|
||||||
return decode();
|
return decode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Makes sure all of the variables are blank
|
||||||
|
*
|
||||||
|
*/
|
||||||
void Caesar::reset(){
|
void Caesar::reset(){
|
||||||
inputString = outputString = "";
|
inputString = outputString = "";
|
||||||
shift = 0;
|
shift = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user