shank03 / XORCryptorLib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XORCryptorLib

Encrypt and decrypt using XOR bitwise operation

About algorithm

Checkout it's Rust implementation here

Adding to CMake project

$ cd <project_folder>
$ git clone https://github.com/shank03/XORCryptorLib -b main XRC

Go to CMakeLists.txt and paste this:

...
# after add_executable

add_subdirectory(XRC)
target_include_directories(${PROJECT_NAME} PUBLIC XRC)
target_link_directories(${PROJECT_NAME} PRIVATE XRC)
target_link_libraries(${PROJECT_NAME} XORCryptorLib)
...

Usage

#include <iostream>
#include "XRC/xor_cryptor.h"

int main() {
    std::string input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ornare.";
    std::string key   = "secret_key";
    std::string encrypted_result;
    XorCryptor::encrypt(input, key, &encrypted_result);
    std::cout << "\nEncrypted:\n"
              << encrypted_result << "\n\n";

    std::string decrypted_result;
    XorCryptor::decrypt(encrypted_result, key, &decrypted_result);
    std::cout << "Decrypted:\n"
              << decrypted_result << "\n\n";
    return 0;
}

About

License:MIT License


Languages

Language:C++ 97.4%Language:CMake 2.6%