openGPMP
Open Source Mathematics Package
cipher.cpp
Go to the documentation of this file.
1 
7 #include <iostream>
8 #include <openGPMP/nt.hpp>
9 #include <stdio.h>
10 #include <string>
11 #include <vector>
12 
13 int main() {
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
User API for OpenGPMP NUMBER THEORY MODULE.
int main()
Definition: cipher.cpp:13