{"id":20030831,"url":"https://github.com/igozdev/xorlit","last_synced_at":"2025-09-20T07:31:11.716Z","repository":{"id":162636351,"uuid":"586140329","full_name":"igozdev/xorlit","owner":"igozdev","description":"Compile time string literal encryptor","archived":false,"fork":false,"pushed_at":"2023-11-03T00:32:22.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T03:32:54.069Z","etag":null,"topics":["compile-time","compiletime","cpp","encryption","encryptor","literal","literals","metaprogramming","obfuscation","obfuscator","string","strings","xor"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igozdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-07T04:25:39.000Z","updated_at":"2024-07-16T02:34:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"27e713ea-ef1e-45d0-b787-90dc039b1723","html_url":"https://github.com/igozdev/xorlit","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/igozdev/xorlit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igozdev%2Fxorlit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igozdev%2Fxorlit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igozdev%2Fxorlit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igozdev%2Fxorlit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igozdev","download_url":"https://codeload.github.com/igozdev/xorlit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igozdev%2Fxorlit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276064220,"owners_count":25578997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-20T02:00:10.207Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compile-time","compiletime","cpp","encryption","encryptor","literal","literals","metaprogramming","obfuscation","obfuscator","string","strings","xor"],"created_at":"2024-11-13T09:28:36.160Z","updated_at":"2025-09-20T07:31:11.480Z","avatar_url":"https://github.com/igozdev.png","language":"C++","readme":"# xorlit\r\n\u003e Compile time string literal encryptor for C++.\r\n\r\n[![license][badge.license]][license]\r\n[![release][badge.release]][release]\r\n[![godbolt][badge.godbolt]][godbolt]\r\n\r\n[badge.license]: https://img.shields.io/badge/license-mit-green.svg\r\n[license]: https://github.com/igozdev/xorlit/blob/main/LICENSE\r\n[badge.release]: https://img.shields.io/github/release/igozdev/xorlit.svg\r\n[release]: https://github.com/igozdev/xorlit/releases/latest\r\n[badge.godbolt]: https://img.shields.io/badge/try_it-on_godbolt-indigo.svg\r\n[godbolt]: https://godbolt.org/z/Ksd36MMo7\r\n\r\n* [Usage](#usage)\r\n* [Example](#example)\r\n\r\n# Usage\r\n## XORLIT\r\nThe `XORLIT` macro can be used to create an encrypted string which evaluates to its original contents (e.g. `XORLIT(\"foo\")` would evalute as the string \"foo\", but be stored as some other encrypted value). As it wraps `xorlit::make_str`, one can pass either one argument, a string literal, or two arguments, a string literal and a key. In the case that one argument is passed, the key used will default to `xorlit::seed`.\r\n\u003e [!WARNING]\r\n\u003e Exercise caution when using `XORLIT`, `xorlit::make_str(__VA_ARGS__).rexor()`, or `xorlit::string`s in any context where they are not explicitly stored, as some compilers, such as MSVC, may sporadically encrypt strings non-constexpr-ly depending on the string literal's content or the context of its usage. It may be advisable to search binary contents for any unencrypted string literals in this case.\r\n\r\n## xorlit::seed\r\n`xorlit::seed` is a `constexpr std::uint_least32_t` which is based on the predefined `__TIME__` macro to generate values. It is the default value used by `xorlit::make_str` and by extension `XORLIT` for the key. Since `xorlit::seed` or `static_cast\u003cchar\u003e(xorlit::seed)` may evaluate to 0, which, in such a case, would lead to an unencrypted string, by defining `XORLIT_SEED_STATIC_ASSERT` before including the `xorlit.hpp` header, a static assertion by the compiler will be enabled to check if `xorlit::seed` is equal to 0.\r\n\r\n## xorlit::string\r\n`xorlit::string` is the provided type for storing encrypted strings. A `xorlit::string` should always be decorated with the `constexpr` specifier to ensure it is stored in its encrypted form. \r\n`xorlit::string` defines the following member functions:\r\n* `xorlit::string::rexor()`: xors the data of the string and returns it.\r\n* `xorlit::string::xor_data()`: returns a new `const char*` with a copy of the string's data xored.\r\n* `xorlit::string::data`: returns the data stored in the string. `const` and non-`const` variants are provided.\r\n* `xorlit::string::key`: returns the key stored in the string.\r\n\u003e [!IMPORTANT]\r\n\u003e Results of `xorlit::string::xor_data()` must be managed manually, whether that be via `delete`, smart pointers, etc.\r\n\r\n# Example\r\n```c++\r\n#include \u003cstring\u003e\r\n#include \u003ciostream\u003e\r\n#include \u003cformat\u003e\r\n#define XORLIT_SEED_STATIC_ASSERT // enable compiler check if xorlit::seed is 0\r\n#include \u003cxorlit.hpp\u003e\r\n\r\nint main()\r\n{\r\n    std::cout\r\n        \u003c\u003c XORLIT(\"Default, xorlit::seed is passed as the key\\n\")\r\n        \u003c\u003c XORLIT(\"Or you can use xorlit::seed yourself\\n\", xorlit::seed + __LINE__) // when passing your own seeds, you should check that they aren't 0\r\n        \u003c\u003c XORLIT(\"Or you can choose your own key\\n\", 12) \u003c\u003c std::endl;\r\n\r\n    constexpr auto s = xorlit::make_str(\"You can manually store a xorlit::string\"); // always declare the results of xorlit::make_str constexpr\r\n    const std::string raw(s.data(), decltype(s)::size);\r\n    const char* original_data = s.xor_data(); // results of xorlit::string::xor_data must be manually managed, smart pointers are recommended\r\n    const std::string original(original_data, decltype(s)::size);\r\n    delete[] original_data;\r\n    std::cout \u003c\u003c std::format(\"Raw: {}\\nOriginal: {}\", raw, original) \u003c\u003c std::endl;\r\n}\r\n\r\n////////////////// Possible output: //////////////////\r\n// Default, xorlit::seed is passed as the key\r\n// Or you can use xorlit::seed yourself\r\n// Or you can choose your own seed\r\n//\r\n// Raw:    ?%p31\u003ep=1\u003e%1\u003c\u003c)p#$?\"5p1p(?\"\u003c9$jj#$\"9\u003e7P\r\n// Original: You can manually store a xorlit::string\r\n```\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figozdev%2Fxorlit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figozdev%2Fxorlit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figozdev%2Fxorlit/lists"}