C++

Updated

kryptic-daemon-client injects your project's secrets into the process environment with setenv (POSIX) or _putenv_s (Windows) during development startup. Zero dependencies, C++17. Outside development it is a no-op, and it never throws.

Source: github.com/dev-kryptic/Kryptic.Cpp.

Install

CMake FetchContent:

include(FetchContent)
FetchContent_Declare(
  kryptic-daemon-client
  GIT_REPOSITORY https://github.com/dev-kryptic/Kryptic.Cpp.git
  GIT_TAG v1.0.0
)
FetchContent_MakeAvailable(kryptic-daemon-client)
target_link_libraries(your_app PRIVATE kryptic-daemon-client)

Or add the sources as a subdirectory:

add_subdirectory(path/to/Kryptic.Cpp)
target_link_libraries(your_app PRIVATE kryptic-daemon-client)

Use

#include <kryptic/kryptic.hpp>
#include <cstdlib>

int main() {
    kryptic::inject();  // before anything reads the environment

    const char* db_url = std::getenv("DATABASE_URL");
}

inject() returns a Result{injected, skipped, reason}. Existing environment variables are never overwritten. Optional overrides:

kryptic::Options options;
options.environment = "staging";
options.project_id = "proj_x";
options.timeout_ms = 2000;
kryptic::inject(options);

Behavior

  • No-op when CPP_ENV/APP_ENV/ENVIRONMENT/ENV indicates production or staging, or when KRYPTIC_DISABLED=true.
  • Finds kryptic.json by walking up from the working directory.
  • Never overwrites environment variables that are already set.
  • macOS/Linux via unix socket, Windows via named pipe. Standard library and OS sockets only.

Environment variables override everything: KRYPTIC_PROJECT_ID, KRYPTIC_ENV, KRYPTIC_SOCKET_PATH, KRYPTIC_TIMEOUT_MS, KRYPTIC_DISABLED, KRYPTIC_SILENT.