diff --git a/b64.h b/b64.h index 3dfa854..b6867e3 100644 --- a/b64.h +++ b/b64.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/encrypt.h b/encrypt.h index ca0128d..b9fff70 100644 --- a/encrypt.h +++ b/encrypt.h @@ -1,7 +1,8 @@ +#pragma once #include "b64.h" #include "vigenere.h" -std::string encrypt(std::string& msg, std::string& key) { +static std::string encrypt(std::string& msg, std::string& key) { std::string b64_str = base64_encode(msg); std::string vigenere_msg = encrypt_vigenere(b64_str, key); // std::cout << vigenere_msg << std::endl; @@ -9,7 +10,7 @@ std::string encrypt(std::string& msg, std::string& key) { } -std::string decrypt(std::string& encrypted_msg, std::string& key) { +static std::string decrypt(std::string& encrypted_msg, std::string& key) { std::string newKey = extend_key(encrypted_msg, key); std::string b64_encoded_str = decrypt_vigenere(encrypted_msg, newKey); std::string b64_decode_str = base64_decode(b64_encoded_str); diff --git a/vigenere.h b/vigenere.h index 9caca46..1bb94cc 100644 --- a/vigenere.h +++ b/vigenere.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include @@ -7,9 +8,9 @@ using namespace std; -std::string AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "; +static std::string AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "; -int index(char c) { +static int index(char c) { for(int ii = 0; ii < AVAILABLE_CHARS.size(); ii++) { if(AVAILABLE_CHARS[ii] == c) { // std::cout << ii << " " << c << std::endl; @@ -20,7 +21,7 @@ int index(char c) { } -std::string extend_key(std::string& msg, std::string& key) { +static std::string extend_key(std::string& msg, std::string& key) { //generating new key int msgLen = msg.size(); std::string newKey(msgLen, 'x'); @@ -36,7 +37,7 @@ std::string extend_key(std::string& msg, std::string& key) { } -std::string encrypt_vigenere(std::string& msg, std::string& key) { +static std::string encrypt_vigenere(std::string& msg, std::string& key) { int msgLen = msg.size(), keyLen = key.size(), i, j; std::string encryptedMsg(msgLen, 'x'); // char newKey[msgLen], encryptedMsg[msgLen], decryptedMsg[msgLen]; @@ -57,7 +58,7 @@ std::string encrypt_vigenere(std::string& msg, std::string& key) { return encryptedMsg; } -std::string decrypt_vigenere(std::string& encryptedMsg, std::string& newKey) { +static std::string decrypt_vigenere(std::string& encryptedMsg, std::string& newKey) { // decryption int msgLen = encryptedMsg.size(); std::string decryptedMsg(msgLen, 'x');