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:
@@ -1,22 +1,33 @@
|
||||
//Ciphers/SourceFiles/Atbash.cpp
|
||||
//Matthew Ellison
|
||||
// Created: 4-30-18
|
||||
//Modified: 4-30-18
|
||||
//Modified: 5-5-18
|
||||
//This file contains the implementation of the Atbash class
|
||||
|
||||
|
||||
#include "../Headers/Atbash.hpp"
|
||||
#include <cctype>
|
||||
|
||||
/**
|
||||
* @brief Construct a new Atbash object
|
||||
*
|
||||
*/
|
||||
Atbash::Atbash(){
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destroy the Atbash object
|
||||
*
|
||||
*/
|
||||
Atbash::~Atbash(){
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Strips all invalid characters from input and sets it to inputString
|
||||
*
|
||||
* @param input The string that you wish to encode or decode
|
||||
*/
|
||||
void Atbash::setInputString(std::string input){
|
||||
//Make sure inputString is empty
|
||||
reset();
|
||||
//Strip all punctuation and whitespace from input and make all letters capital
|
||||
for(int cnt = 0;cnt < input.size();++cnt){
|
||||
char letter = input[cnt];
|
||||
@@ -32,14 +43,29 @@ void Atbash::setInputString(std::string input){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the stripped inputString
|
||||
*
|
||||
* @return The current inputString
|
||||
*/
|
||||
std::string Atbash::getInputString() const{
|
||||
return inputString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the current outputString
|
||||
*
|
||||
* @return The current outputString
|
||||
*/
|
||||
std::string Atbash::getOutputString() const{
|
||||
return outputString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Uses the Atbash cipher to encode inputString and store it in outputString
|
||||
*
|
||||
* @return The encoded inputString (outputString)
|
||||
*/
|
||||
std::string Atbash::encode(){
|
||||
//Step through every element in the inputString and shift it the correct amount
|
||||
for(int cnt = 0;cnt < inputString.size();++cnt){
|
||||
@@ -49,14 +75,25 @@ std::string Atbash::encode(){
|
||||
return outputString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A simple interface that makes sure inputString is set and encodes it using the Atbash cipher
|
||||
*
|
||||
* @param input The string that you wish to encode
|
||||
* @return The encoded string
|
||||
*/
|
||||
std::string Atbash::encode(std::string input){
|
||||
//Make sure everything is empty before you begin
|
||||
reset();
|
||||
setInputString(input);
|
||||
return encode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Uses the Atbash cipher to decode inputString and store it in outputString
|
||||
*
|
||||
* @return The decoded inputString (outputString)
|
||||
*/
|
||||
std::string Atbash::decode(){
|
||||
//Make sure outputString is empty
|
||||
outputString = "";
|
||||
for(int cnt = 0;cnt < inputString.size();++cnt){
|
||||
outputString += (inputString[cnt] + 25 - (2 * (inputString[cnt] - 'A')));
|
||||
}
|
||||
@@ -64,11 +101,23 @@ std::string Atbash::decode(){
|
||||
return outputString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A simple interface that makes sure inputString is set and decodes it using the Atbash cipher
|
||||
*
|
||||
* @param input The string that you wish to encode
|
||||
* @return The decoded string
|
||||
*/
|
||||
std::string Atbash::decode(std::string input){
|
||||
//Make sure everything is empty before you begin
|
||||
reset();
|
||||
setInputString(input);
|
||||
return decode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resets all variables
|
||||
*
|
||||
*/
|
||||
void Atbash::reset(){
|
||||
inputString = outputString = "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user