### Quick Example of xorstr Usage Source: https://github.com/justasmasiulis/xorstr/blob/master/README.md Demonstrates how to use the xorstr_ macro to encrypt and print a string at runtime. This is the most straightforward way to use the library. ```cpp int main() { std::puts(xorstr_("an extra long hello_world")); } ``` -------------------------------- ### GCC Assembly Output for Quick Example Source: https://github.com/justasmasiulis/xorstr/blob/master/README.md Shows the assembly code generated by GCC for the quick example, illustrating how the string data is embedded and processed. ```asm main: movabs rax, -4762152789334367252 push rbp mov rbp, rsp and rsp, -32 sub rsp, 64 mov QWORD PTR [rsp], rax mov rdi, rsp movabs rax, -6534519754492314190 mov QWORD PTR [rsp+8], rax movabs rax, -2862143164529545214 mov QWORD PTR [rsp+16], rax movabs rax, -4140208776682645948 mov QWORD PTR [rsp+24], rax vmovdqa ymm1, YMMWORD PTR [rsp] movabs rax, -2550414817236710003 mov QWORD PTR [rsp+32], rax movabs rax, -4595755740016602734 mov QWORD PTR [rsp+40], rax movabs rax, -5461194525092864914 mov QWORD PTR [rsp+48], rax movabs rax, -4140208776682645984 mov QWORD PTR [rsp+56], rax vpxor ymm0, ymm1, YMMWORD PTR [rsp+32] vmovdqa YMMWORD PTR [rsp], ymm0 vzeroupper call puts xor eax, eax leave ret ``` -------------------------------- ### xorstr Macro Source: https://github.com/justasmasiulis/xorstr/blob/master/README.md The `xorstr` macro is used to create an encrypted `xor_string` instance at compile time. It takes a string literal as input. ```APIDOC ## #define xorstr(string) ### Description This macro creates an encrypted `xor_string` string instance. ### Parameters - **string** (string literal) - The string to be encrypted. ``` -------------------------------- ### xor_string Struct Definition Source: https://github.com/justasmasiulis/xorstr/blob/master/README.md Outlines the structure of xor_string, including its size, encryption methods, and accessors for the internal storage. ```cpp struct xor_string { using size_type = std::size_t; using value_type = CharT; using pointer = value_type*; using const_pointer = const value_type*; // Returns string size in characters, not including null terminator. constexpr size_type size() const; // Runs the encryption/decryption algorithm on the internal storage. void crypt() noexcept; // Returns const pointer to the storage, without doing any modifications to it. const_pointer get() const; // Returns non const pointer to the storage, without doing any modifications to it. pointer get(); // Runs crypt() and returns the pointer to the internal storage. pointer crypt_get(); } ``` -------------------------------- ### xorstr_ Macro Source: https://github.com/justasmasiulis/xorstr/blob/master/README.md The `xorstr_` macro provides a convenient way to instantly decrypt a string encrypted by `xorstr`. It calls the `crypt_get()` method on the `xor_string` instance. ```APIDOC ## #define xorstr_(string) ### Description This macro instantly decrypts a string encrypted by `xorstr`. ### Parameters - **string** (string literal) - The encrypted string to decrypt. ``` -------------------------------- ### xorstr Macro Definition Source: https://github.com/justasmasiulis/xorstr/blob/master/README.md Defines the primary xorstr macro for creating encrypted xor_string instances and the xorstr_ macro for immediate decryption. ```cpp // This macro creates an encrypted xor_string string instance. #define xorstr(string) xor_string<...>{string} // For convenience sake there is also a macro to instantly decrypt the string #define xorstr_(string) xorstr(string).crypt_get() ``` -------------------------------- ### xor_string Struct Source: https://github.com/justasmasiulis/xorstr/blob/master/README.md The `xor_string` struct is the core component that holds the encrypted string data and provides methods for manipulation and access. ```APIDOC ## struct xor_string ### Description Represents an encrypted string that can be decrypted at runtime or compile time. ### Methods #### `size()` - **Description**: Returns the string size in characters, not including the null terminator. - **Return Type**: `constexpr size_type` #### `crypt()` - **Description**: Runs the encryption/decryption algorithm on the internal storage. - **Note**: This method modifies the internal storage. #### `get()` - **Description**: Returns a const pointer to the internal storage without performing any modifications. - **Return Type**: `const_pointer` #### `get()` (non-const overload) - **Description**: Returns a non-const pointer to the internal storage without performing any modifications. - **Return Type**: `pointer` #### `crypt_get()` - **Description**: Runs `crypt()` and returns a pointer to the internal storage. This effectively decrypts the string and returns a pointer to the decrypted data. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.