Linked Questions
11 questions linked to/from Compile time string encryption using constexpr
166 votes
21 answers
112k views
Conveniently Declaring Compile-Time Strings in C++
Being able to create and manipulate strings during compile-time in C++ has several useful applications. Although it is possible to create compile-time strings in C++, the process is very cumbersome, ...
109 votes
14 answers
49k views
Techniques for obscuring sensitive strings in C++
I need to store sensitive information (a symmetric encryption key that I want to keep private) in my C++ application. The simple approach is to do this: std::string myKey = "...
107 votes
8 answers
53k views
Computing length of a C string at compile time. Is this really a constexpr?
I'm trying to compute the length of a string literal at compile time. To do so I'm using following code: #include <cstdio> int constexpr length(const char* str) { return *str ? 1 + length(...
32 votes
7 answers
28k views
Generate random numbers in C++ at compile time
I'm trying to precompute random values using C++11's random library at compile time. I'm mostly following examples. What am I doing wrong here? using namespace std; #include <iostream> #include ...
23 votes
8 answers
31k views
Compile-time string encryption
I don't want reverse-engineers to read the plain-text of hardcoded strings in my application. The trivial solution for this is using a simple XOR-Encryption. The problem is I need a converter and in ...
17 votes
4 answers
17k views
Encrypting / obfuscating a string literal at compile-time
I want to encrypt/encode a string at compile time so that the original string does not appear in the compiled executable. I've seen several examples but they can't take a string literal as argument. ...
4 votes
4 answers
2k views
How to parse a static const std::string in compilation time?
I have some SQL queries with binds in my C++ code, those queries are static const std::string, because those queries are complex it is very easy to be wrong with some details. I would like to do some ...
4 votes
1 answer
2k views
Replacing magic ID numbers with random IDs generated at compile-time
My app contains numerous IDs. I want to eventually make the code viewable by others, but not make it easy for runtime reverse engineers to look for easily known IDs. Also, during development it is ...
3 votes
1 answer
1k views
Compile-time std::string obfuscation
I trying to write function, for compile-time hide (obfuscate) text strings in the binary code. Purpose: to disable easy search and modify text messages with binary editor. Algorithm is simple: convert ...
4 votes
2 answers
585 views
Compile-time string compression with C++17 and earlier
I have an application that uses strings with long chains of repeated characters. I want to add them to the binary in compressed/obfuscated form. I'm currently using a modified RLE algorithm for ...
1 vote
0 answers
187 views
Function (or Call) Overload when using literal as constexpr variable
Hi (sorry for the title - I couldnt make it more meaningfull), I am using encryption of string literals using constexpr from here: Compile time string encryption using constexpr I use it to hide ...