Skip to content

dermojo/spsl

Repository files navigation

SPSL - Special Purpose Strings Library

Travis-CI status AppVeyor status codecov

SPSL is a header-only library for "special" string implementations. It contains the following string class templates:

  • ArrayString/ArrayStringW: Purely stack based string, similar to "plain" C arrays.
  • PasswordString/PasswordStringW: String variant for sensitive data. All memory used by this string implementation is locked in RAM (i.e. it may not be swapped to disk) and is wiped before it's returned to the OS.

If you're interested in the motivation behind these templates, check out the Motivation document. If you're interested in the nitty gritty details of how this library works, head over to Implementation.

Getting started

SPSL is a header-only library, so you don't need to compile anything. Just download it, include it in your project and you're good to go:

#include <spsl.hpp>
spsl::ArrayString<64> a1("I'm a stack-based string and can store 64 characters + NUL");
spsl::ArrayStringW<32> a2(L"Wide characters are ok, too.");
spsl::PasswordString pw1("I'm a secret!");
spsl::PasswordStringW pw2(L"Dream on...");

However, there are a lot of unit tests in this library. If you want to run them (to check compatibility with your platform or if you played with some library code), the next sections are for you.

Dependencies

The SPSL itself only relies on the STL and has no dependencies. To compile the tests, you'll need:

(A copy of the Catch2 test framework is contained.)

Supported compilers (we'll, the ones I've tested) include GCC 4.9+ and clang 4+ on Linux and Microsoft Visual Studio 2015+.

Make sure to clone this repository with:

git clone --recurse-submodules https://github.com/dermojo/spsl.git

Running the tests

SPSL comes with a lot of unit tests. They are compiled into the testlib executable, which can be run standalone or from cmake/ctest.

To build and run all tests, run the usual CMake commands:

mkdir build
cd build
cmake ..
cmake --build .
ctest -VV

License

This project is licensed under the MIT License - see the LICENSE file for details.

tl;dr: Feel free to use and modify the code or to include it in your commercial application.

Acknowledgments

This library uses the MurmurHash3 hash functions, copied thankfully from https://github.com/aappleby/smhasher. Thanks a lot!