You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Avril
4199c0b3de
|
4 years ago | |
---|---|---|
test | 4 years ago | |
.gitignore | 4 years ago | |
Makefile | 4 years ago | |
README.md | 4 years ago | |
cfrob.hpp | 4 years ago |
README.md
Compile-time memfrob()
glibc has a function in string.h
called memfrob()
which applies ROT13 to an arbitrary byte buffer.
This small C++20 header allows you to do this at compile time to trivially obscure string literals without the literal itself appearing in the binary anywhere at all.
Usage
The literals can be created and stored as a sized char
array, or as a C string pointer.
#include "cfrob.hpp"
const auto easter_egg = "Something cool"_frob;
const char* c_like_easter_egg = "Something cool"_frob;
To reverse just apply ROT13 on to the string again.
auto string2 = strdup(easter_egg);
memfrob(string2, strlen(easter_egg));
// `string2` now contains the string "Something cool"
free(string2);
Test
Run make test
to build and run the test that ensures the original string literal does not appear anywhere in the outputted binary.
License
Public domain.