openGPMP
Open Source Mathematics Package
Functions
cipher.cpp File Reference
#include <iostream>
#include <openGPMP/nt.hpp>
#include <stdio.h>
#include <string>
#include <vector>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void  )
Examples
cipher.cpp.

Definition at line 13 of file cipher.cpp.

13  {
14  /*
15  * Provide some details on how to use this algorithm
16  */
17  std::cout << "<--------------------------------------------------"
18  "---->\n\n";
19 
20  // declare CIPHER class obj
21  gpmp::Cipher cc;
22 
23  /*
24  * declare some key values and strings to hash
25  */
26  std::cout << "CAESAR CIPHER EXAMPLE\n\n";
27 
28  std::string text0 = "Plaintext";
29  int shift_key_0 = 5;
30  std::string hashtext_0 = cc.caesar(text0, shift_key_0);
31  std::cout << "Hashtext0 = " << hashtext_0 << std::endl;
32 
33  std::string text1 = "ATTACKATONCE";
34  int shift_key_1 = 4;
35  std::string hashtext_1 = cc.caesar(text1, shift_key_1);
36  std::cout << "Hashtext1 = " << hashtext_1 << std::endl;
37 
38  /* TESTING MONOALPHABETIC SUBSTITUION KEYWORD CIPHER */
39  std::cout << "\nMONOALPHABETIC SUBSTITUION KEYWORD CIPHER EXAMPLE\n\n";
40 
41  std::string shift_key_2 = "Computer";
42  std::string text2 = "Password";
43  // encode the plaintext
44  std::string encoded_text = cc.keyword_encode(shift_key_2);
45  // call the cipher function
46  std::string hashtext_2 = cc.keyword(text2, encoded_text);
47  std::cout << "Hashtext2 = " << hashtext_2 << std::endl;
48 
49  std::string text_4 = "P455W0RD";
50  std::string key_shift_4 = "IN1T_d";
51 
52  std::string encoded_text_4 = cc.keyword_encode(key_shift_4);
53  std::string hashtext_4 = cc.keyword(text_4, encoded_text_4);
54  std::cout << "Hashtext4 = " << hashtext_4 << std::endl;
55 
56  return 0;
57 }
std::string keyword_encode(std::string key)
Definition: cipher.cpp:63
std::string keyword(std::string plaintext, std::string encoded_text)
Definition: cipher.cpp:99
std::string caesar(std::string plaintext, int64_t key)
Definition: cipher.cpp:46

References gpmp::Cipher::caesar(), gpmp::Cipher::keyword(), and gpmp::Cipher::keyword_encode().