Home

Awesome

crystr | Compile-Time Strings and Numbers Encryption for C++20

Description

This repository provides a compile-time strings and numbers encryption mechanism based on xor bitwise operations using mathematical operations at compile-time in order to make the strings and numbers challenging to decompile.
Users can easily encrypt their strings using the crystr macro provided in the header, and numbers using crynum and crynum_long.
The repository includes an example demonstrating the usage of crystr, crynum and crynum_long to use encrypted strings and numbers.
It's recommended, but not necessarily, to disable the optimization under C/C++ -> Optimization -> "Optimization" and "Whole Program Optimization"
When using the virtual functions option it needs RTTI OFF (Run-Time Type Information under C/C++ -> Language (/GR-))

Key Aspects

How it shows

Look here
How it shows using inline functions option

Repository Structure

Usage Example

The repository includes an example demonstrating the usage of the crystr, crynum, crynum_long macros:

main.cpp

//#include "crycall.hpp" // see https://github.com/Android1337/crycall for an all-potential virtual implementation
#include "crystr.hpp"

int main() {
    auto encrypted_str = crystr("Hello, this is an encrypted string!");
    printf("Decrypted String: %s\n", encrypted_str.decrypt());
    encrypted_str.clear();

    auto encrypted_int = crynum(1234);
    printf("Decrypted Int: %d\n", encrypted_int.decrypt());
    encrypted_int.clear();

    auto encrypted_double = crynum_long(1.234);
    printf("Decrypted Double: %f\n", encrypted_double.decrypt());
    encrypted_double.clear();

    return 0;
}