Advertisement
Phr0zen_Penguin

Simple Crypto Header File

Oct 4th, 2014
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.39 KB | None | 0 0
  1. /*==================================================================================================
  2.   --------------------------------------------------------------------------------------------------
  3.   [simpleCrypto.hpp]
  4.     Main header file for the simpleCrypto program.
  5.  
  6.         (c) Damion 'Phr0z3n.dev' Tapper, 2014.
  7.         Email: Phr0z3n.Dev@Gmail.com
  8.   --------------------------------------------------------------------------------------------------
  9.   ==================================================================================================*/
  10.  
  11. /*===============================================--=================================================
  12.                                         CONSTANT DEFINITIONS
  13.   --------------------------------------------------------------------------------------------------*/
  14. /**
  15.  * NOTE:
  16.  * There is no doubt that there are header files, that already contain predefined logic
  17.  * (_WIN32, _POSIX, etc), that could be used to determine respective environments.
  18.  * There is also no doubt that there is always pros and cons, regarding using these predefined logics.
  19.  * The overwhelming con: the ever evolving OSes.  What about _WIN64, and _POSIX64?  Besides, how lazy
  20.  * are't though to not want to comment/uncomment a single line in order to make things work flawlessly?
  21.  **/
  22. #define _WINDOWS    0x001
  23. #define _NIX        0x002
  24.  
  25. /**
  26.  * The program performs only two fundamental file operations: reading and writing (no appending, etc.).
  27.  **/
  28. #define _FILE_READ          'r'
  29. #define _FILE_WRITE         'w'
  30.  
  31. /**
  32.  * Likewise, only two file flags are utilised.
  33.  **/
  34. #define _FILE_READ_FLAG     std::ios_base::in
  35. #define _FILE_WRITE_FLAG    std::ios_base::out
  36.  
  37. /*===============================================--=================================================
  38.                                     (CCRYPT0) CLASS DEFINITION
  39.   --------------------------------------------------------------------------------------------------*/
  40. class CCrypt0
  41. {
  42.     /**
  43.      * PUBLIC MEMBERS
  44.      *
  45.      * NOTE:
  46.      * The members are arranged in the following specific order to adhere to standard coding
  47.      * conventions.
  48.      **/
  49.     public:
  50.         /**
  51.          * The CCrypt0 class constructor.
  52.          **/
  53.         CCrypt0();
  54.  
  55.         /**
  56.          * The CCrypt0 class destructor.
  57.          **/
  58.         ~CCrypt0();
  59.  
  60.         /**
  61.          * FUNCTION PROTOTYPES
  62.          *
  63.          * The mainMenu function prototype.
  64.          **/
  65.         int mainMenu(void);
  66.  
  67.         /**
  68.          * The encryptDecryptText/FileText function prototypes.
  69.          **/
  70.         void encryptDecryptText(void);
  71.         void encryptDecryptFileText(void);
  72.  
  73.         /**
  74.          * The outputMenu function prototype.
  75.          **/
  76.         void outputMenu(void);
  77.  
  78.         /**
  79.          * The displayText function prototype.
  80.          **/
  81.         void displayText(void);
  82.  
  83.         /**
  84.          * The doEncrypt/Decrypt function prototypes.
  85.          **/
  86.         inline void doEncrypt(void);
  87.         inline void doDecrypt(void);
  88.  
  89.         /**
  90.          * The fileNameEntry function prototype.
  91.          *
  92.          * NOTE:
  93.          * Dynamic conventions are implemented in the code to make the program function as versatile
  94.          * and efficient as possible: some functions take (lesser-used variables) parameters while,
  95.          * the more fundamentally utilised variables are set in and retrieved from (private) variables
  96.          * implemented in the (base) class itself.  Then there is the issue of 'stack labour'.
  97.          **/
  98.         inline void fileNameEntry(char);
  99.  
  100.         /**
  101.          * The readWriteText function prototype.
  102.          **/
  103.         void readWriteText(void);
  104.  
  105.         /**
  106.          * The printFileWarningError function prototype.
  107.          **/
  108.         void printFileWarningError(void);
  109.  
  110.         /**
  111.          * The clearScreen function prototype.
  112.          **/
  113.         void clearScreen(void);
  114.  
  115.         /**
  116.          * Function to turn on/off console echo.
  117.          **/
  118.         void SetStdinEcho(bool);
  119.         /**
  120.          * NOTE:
  121.          * The code implemented in the last two functions are definitely reusable and deserve their own
  122.          * class.  Their prototypes are declared in this class merely by convention and for efficiency.
  123.          **/
  124.  
  125.         /**
  126.          * ACCESSOR FUNCTIONS
  127.          *
  128.          * The set/getMainMenuOpt accessor functions.
  129.          **/
  130.         void setMainMenuOpt(char _mainMenuOpt){ mainMenuOpt = _mainMenuOpt; }
  131.         char getMainMenuOpt(void){ return mainMenuOpt; }
  132.  
  133.         /**
  134.          * The set/getFileName accessor functions.
  135.          **/
  136.         void setFileName(std::string *_fileNameBuffer){ fileName = *_fileNameBuffer; }
  137.         std::string getFileName(void){ return fileName; }
  138.  
  139.         /**
  140.          * The set/getFileFlag accessor functions.
  141.          **/
  142.         void setFileFlag(std::ios_base::openmode _fileFlag){ fileFlag = _fileFlag; }
  143.         const std::ios_base::openmode getFileFlag(void){ return static_cast<const std::ios_base::openmode>(fileFlag); }
  144.  
  145.         /**
  146.          * The set/getFileWarningError accessor functions.
  147.          *
  148.          * NOTE:
  149.          * This concept is borrowed from, but is way superior to, the (unguarded) errno global
  150.          * variable in C.
  151.          **/
  152.         void setFileWarningError(unsigned short _fileWarningError){ fileWarningError = _fileWarningError; }
  153.         const unsigned short getFileWarningError(void){ return static_cast<const unsigned short>(fileWarningError); }
  154.  
  155.         /**
  156.          * The set/getCryptBuffer accessor functions.
  157.          **/
  158.         void setCryptBuffer(std::string *_cryptBuffer){ cryptBuffer = *_cryptBuffer; }
  159.         std::string getCryptBuffer(void){ return cryptBuffer; }
  160.  
  161.     /**
  162.      * PRIVATE MEMBERS
  163.      *
  164.      * NOTE:
  165.      * Merely variables paramount to the operations in the core of the program.
  166.      **/
  167.     private:
  168.                     char                    mainMenuOpt;
  169.  
  170.                     std::string             fileName;
  171.                     std::ios_base::openmode fileFlag;
  172.         unsigned    short                   fileWarningError;
  173.  
  174.                     std::string             cryptBuffer;
  175.  
  176.  
  177.     protected:
  178. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement