RainTextCore is a robust library focused on strong data encryption. Originating as a bachelor's thesis, this open-source project is dedicated to providing a secure method of encrypting plaintext using a unique iterative process. RainTextCore is licensed under the MIT License, allowing for widespread use and contribution.
RainTextCore employs a sophisticated encryption algorithm that requires the key to be at least three times the maximum length of the encryption key. The encryption process involves appending a 0xFF
byte to the end of the plaintext, followed by a series of operations based on the specified number of iterations. In each iteration, a cipher is randomly selected, and the key is divided into necessary segments. Two segments are used to generate an Initialization Vector (IV), and one as the cipher key. The indices of these segments (pre_salt_index_
, init_vector_index_
, key_index_
, and cipher_index_
) are appended to the end of the encrypted text, ensuring the IV is not stored with the key.
Decryption is initiated by a loop that continues until a 0xFF
byte is detected at the end of the encrypted text, indicating the start of the decryption indexes. The long key is then split into arrays of the required length to regenerate the IV and to provide the decryption key. After removing any auxiliary bytes, the text is decrypted. This process repeats until the 0xFF
byte is encountered, signaling the end of decryption and the return of the decrypted text.
RainTextCore comes with a Linux script to facilitate easy compilation across different platforms and CPU architectures. Here is script help:
Usage: $0 [OPTION]... [PATH]
Compile RainTextCore project for various platforms and CPU architectures.
OPTIONS:
-a, --all Compile for all supported platforms (Linux, Windows) and CPUs.
-l, --linux Compile for Linux. Defaults to x86_64 if no architecture is specified.
Supported architectures for Linux:
all Target all architectures
x86 Architecture x86
x86_64 Architecture x86_64 (default)
v8 Architecture arm64-v8a
am64 Architecture aarch64/arm64
-w, --windows Compile for Windows. Defaults to x86_64 if no architecture is specified.
Supported architectures for Windows:
all Target all architectures
x86 Architecture x86
x86_64 Architecture x86_64 (default)
am64 Architecture arm64
-j [N] Specifies the number of jobs (threads) to run simultaneously.
[PATH] Absolute path that specifies where the project directory is.
Defaults to the current directory.
Defaults:
Linux: x86_64
Windows: x86_64
Examples:
$0 # Compile for default architectures of all platforms.
$0 --all # Compile for all platforms and architectures.
$0 -l # Compile for all Linux architectures.
$0 -l v8 # Compile for Linux arm64-v8a.
The script supports a range of options for targeted compilation, including platform-specific and architecture-specific builds.
RainTextCore utilizes well-known libraries such as Argon, CryptoPP, and Scrypt to ensure top-notch security and performance. It is built using CMake and includes a prepared Docker environment for builds. The output of the project is static libraries designed for easy integration and use.
The library is designed for simplicity in use, catering to both beginners and experienced developers. Its integration into projects is straightforward, thanks to the static libraries generated by the build process.
example:
// std::vector<uint8_t> key = { ... }
// std::vector<uint8_t> plain_text = { ... }
auto rain_text_core =std::make_unique<rain_text_core::RainTextCore>(10, key, plain_text);
// encrypting
std::vector<uint8_t> cipher; //output
rain_text_core->Encrypt(cipher);
// set new text to work
rain_text_core->SetText(cipher);
// decripting
std::vector<uint8_t> restored_plain_text; //output
rain_text_core->Decrypt(restored_plain_text);
We welcome contributions from the community. Whether you're a seasoned developer or just starting out, your input and improvements are valued.
Special thanks are given to the external libraries that make RainTextCore a powerful tool for encryption.
- script- implemantatin by @technion
- Crypto++ - special thanks to @abdes for Crypto++ for modern cmake
- Argon2 - implementation by @zpalmtree