PxCrypt v0.1
Encrypt data within an image
|
PxCrypt is a C++ library that provides a codec for storing arbitrary binary data within images, a form of steganography.
This project also includes a command-line encoder/decoder utility that allows for convenient access to the library's encoding/decoding facilities and acts as a sample application built using the library as a dependency. For more information regarding the application, see the project's GitHub page.
PxCrypt is provided as a CMake package composed of a single library, several public header files, and the encoder/decoder utility.
Codec
- The main libraryUtility
- The encoder/decoder utilityIf no components are specified in the find_package()
call, only the main library will be imported.
PxCrypt is also composed to gracefully support CMake's FetchContent mechanism. All exportable targets are named to match their corresponding component when packaged, and feature alias targets with the same names when building. This allows consumers to access the targets via the same name regardless of whether they are using a pre-built package of PxCrypt or building it as a sub-project.
For example, the Codec
component corresponds to the pxcrypt_codec
target, which can also be referred to via PxCrypt::Codec
.
1) Download the latest Release
2) Place the package somewhere CMake can find it
3) Import the package
4) Link to the library
5) Include the desired public headers in your code
6) Review the rest of the documentation, primarily encode.h and decode.h. Also see PxCrypt::EncType for the difference between the available encoding strategies.
The latest generally stable source is available in the 'main' branch of https://github.com/oblivioncth/PxCrypt, while the most up-to-date source can be found in the 'dev' branch.
The requirements for building from Git are the same as for using PxCrypt, with the obvious exception that Doxygen (as well as Graphviz) is also needed to build the documentation.
If newer to working with Qt, it is easiest to build from within Qt creator as it handles a large portion of environment setup, including adding Qt to CMake's package search list, automatically. Simply make sure that a kit is configured in Qt Creator that uses a compatible version of Qt, open the CMakeLists.txt file as a project, and build with the desired configuration.
Alternatively, you can use the qt-cmake
wrapper for similar Qt environment automation when building the project on the command-line, which is shown further down.
The CMake project is designed to be used with multi-configuration generators such as Visual Studio or Ninja Multi-Config (recommended), and may require some tweaking to work with single configuration generators.
PXCRYPT_DOCS
- Set to ON
in order to generate the documentation target (OFF)PXCRYPT_TESTS
- Set to ON
in order to generate the test targets (OFF)BUILD_SHARED_LIBS
- Build PxCrypt as a shared library instead of a static one (OFF)all
- Builds the PxCrypt library and encoder/decoder utilityinstall
- Installs the build output into CMAKE_INSTALL_PREFIX
pxcrypt_base
- Builds the PxCrypt librarypxcrypt_frontend
- Builds the PxCrypt encoder/decoder utilitypxcrypt_docs
- Builds the PxCrypt documentationpxcrypt_tst_...
- Builds the various test targets. To actually run tests, just build the general CMake tests target test
.pxcrypt
- Installs top-level files (README.md, CMake package configuration files, etc.)pxcrypt_base
- Installs the built librarypxcrypt_frontend
- Installs the built encoder/decoder utilitypxcrypt_docs
- Installs the built documentationIf PxCrypt is configured as a sub-project, its install components are automatically removed from the all
component, as to not pollute the install directory of the top-level project. They can still be installed by directly referencing their component names as shown above.
In order for the pxcrypt_docs
target to be generated the CMake cache variable PXCRYPT_DOCS must be set to ON when CMake is invoked:
The PxCrypt documentation supports two optional, but highly recommended features:
In order to enable these features, the CMake variables QT_DOCS_DIR and QT_HELP_GEN_PATH respectively must be available. PxCrypt tries to set them automatically according to the following defaults, but these can be overridden by passing definitions for the variables to CMake on the command line via -D
.
# Optional documentation defaults # Here <QT_ROOT> refers to the install directory of a given Qt build QT_DOCS_DIR: <QT_ROOT>/doc (Windows) QT_HELP_GEN_PATH: <QT_ROOT>/bin/qhelpgenerator.exe (Linux) QT_HELP_GEN_PATH: <QT_ROOT>/libexec/qhelpgenerator
If supplying QT_DOCS_DIR manually, it must be set to the root path that contains documentation for the Qt version you are building with. It should look something like this:
doc/ ├── config ├── global ├── qdoc ├── qmake ├── qtcmake ├── qtconcurrent ├── qtcore ├── ... ├── qdoc.qch ├── qmake.qch └── ... # In this case QT_DOCS_DIR should point to the directory 'doc'.
The path for this documentation varies depending on how you obtained Qt, but is generally placed in one of two locations:
# Official Qt Builds from Maintenance Tool/Installer <QT_SOFTWARE>/Docs/Qt-<QT_VERSION> # Self-built Qt <QT_ROOT>/doc # NOTE: # By default on Windows <QT_SOFTWARE> is C:\Program Files\Qt # On Linux it is often /usr/local/Qt
The project contains a suite of tests to ensure that the library functions as intended. They will be expanded upon as the library matures.
By default, the CMakeLists project configures CPack to create an artifact ZIP containing:
The following is the general build process required to successfully generate this package via a shadow build on Windows. Adjust the configuration as you see fit:
If you want to use PxCrypt compiled from source directly as a dependency in your CMake project and don't care about the intermediary redistributables, it is recommended to do the following.
Create 'FetchPxCrypt.cmake' and add it to CMAKE_MODULE_PATH:
Then in your CMake project:
This allows for more flexibility in downstream projects as they can more easily alter the configuration of PxCrypt on-the-fly as needed.