openGPMP
Open Source Mathematics Package
Examples

See the openGPMP/samples folder for many more examples on how to use openGPMP.

Example C++ driver file for running Caesar Cipher & Mono-Alphabetic Substitution Keyword cipher:

#include <iostream>
#include <string>
// include the openGPMP Number Theory header
#include <openGPMP/nt.hpp>
int main() {
// declare CIPHER class obj (this lies within the gpmp namespace)
/* CAESAR CIPHER */
std::string text0 = "Plaintext";
int shift_key_0 = 5;
std::string hashtext_0 = cc.C_cipher(text0, shift_key_0);
std::cout << "Hashtext0 = " << hashtext_0 << std::endl;
/* TESTING MONOALPHABETIC SUBSTITUION KEYWORD CIPHER */
std::string shift_key_2 = "Computer";
std::string text2 = "Password";
// encode the plaintext
std::string encoded_text = cc.KC_encode(shift_key_2);
// call the cipher function
std::string hashtext_2 = cc.KC_cipher(text2 , encoded_text);
std::cout << "Hashtext2 = " << hashtext_2 << std::endl;
return 0;
}
int main(int argc, char **argv)
Definition: Mandelbrot.c:94
User API for OpenGPMP NUMBER THEORY MODULE.

A Python example showing the same functionalities.

#!/usr/bin/python3
from pygpmp import nt
def main():
c = nt.Cipher()
ciph = c.caesar("Plaintext", 5)
print(ciph)
ciph_1 = c.caesar("ATTACKATONCE", 4)
print(ciph_1)
text = "Password"
shift = "Computer"
encoded_text = c.keyword_encode(shift)
hashtext = c.keyword(text, encoded_text)
print(hashtext)
if __name__ == "__main__":
main()