Git Product home page Git Product logo

cpp-cryptlite's Introduction

=======================================================================
 DESCRIPTION
=======================================================================

=======================================================================
 DEPENDENCIES
=======================================================================
<boost/utility.hpp>


=======================================================================
 SYNOPSIS
=======================================================================
#include <cryptlite/base64.h>
#include <cryptlite/sha1.h>
#include <cryptlite/sha256.h>
#include <cryptlite/hmac.h>
#include <boost/cstdint.hpp>

using namespace cryptlite;

// base64 encoding
std::string b64 = base64::encode_from_string("foobarbuz");

std::vector<boost::uint8_t> decoded_v;
base64::decode(b64, decoded_v);

std::string decoded_str;
base64::decode(b64, decoded_str);


boost::shared_array<boost::uint8_t> arr;
std::size_t len;
boost::tie(arr, len) = base64::decode_to_array(b64);

// sha1 hash
boost::uint8_t sha1digest[sha1::HASH_SIZE];
sha1::hash("foobar", sha1digest);

// hex-formatted sha1 hash
std::string sha1hex = sha1::hash_hex("foobar");

// base64-formatted sha1 hash
std::string sha1base64 = sha1::hash_base64("foobar");

// sha256 hash
boost::uint8_t sha256digest[sha256::HASH_SIZE];
sha256::hash("foobar", sha256digest);

// hex-formatted sha256 hash
std::string sha256hex = sha256::hash_hex("foobar");

// base64-formatted sha256 hash
std::string sha256base64 = sha256::hash_base64("foobar");

// calculate hmac-sha1
boost::uint8_t hmacsha1digest[sha1::HASH_SIZE];
hmac<sha1>::calc("basestring", "key", hmacsha1digest);

// calculate hex-formatted hmac-sha1
std::string hmacsha1hex = hmac<sha1>::calc_hex("basestring", "key");

// calculate hmac-sha256
boost::uint8_t hmacsha256digest[sha256::HASH_SIZE];
hmac<sha256>::calc("basestring", "key", hmacsha256digest);

// calculate hex-formatted hmac-sha256
std::string hmacsha256hex = hmac<sha256>::calc_hex("basestring", "key");

=======================================================================
 INSTALL
=======================================================================
This is header-only library.
So, copying include/cryptlite/*.h into your project directory is the easiest way.

or

1. cd build
2. cmake .. -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release

parameters
    - BUILD_SHARED_LIBS (ON|OFF)
    - CMAKE_BUILD_TYPE (Debug|Release)
    - CMAKE_INSTALL_PREFIX (/usr/local)

3. make
4. make test
5. make install

cpp-cryptlite's People

Contributors

lyokato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cpp-cryptlite's Issues

Modernize based on C++14 or C++17?

Are you accepting pull requests?

C++14 is now 10 years old. #include <cstdint>, std::shared_ptr, making classes non-copyable are now first class language and library features. Do you have any objections to an update rather than a fork?

Pthread does not found by the gtest-all: instruction does not works

For the manual of the Readme file, I've just created a build directory, run cmake as it follows on the second point of manual, and tried to call "make".
But I've got a problem:


 Wed 21 Apr - 12:31  ~/projects/github/cpp-cryptlite   origin ☊ master ✔ 
 user@localhost  mkdir build

 Wed 21 Apr - 12:31  ~/projects/github/cpp-cryptlite   origin ☊ master ✔                                                                                                 user@localhost  cd build
                                                                                                                                                                             Wed 21 Apr - 12:31  ~/projects/github/cpp-cryptlite/build   origin ☊ master ✔ 
 user@localhost  cmake .. -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release                                                                                              -- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1                                                                                                                            -- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done                                                                                                                                     -- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features                                                                                                                                             -- Detecting C compile features - done
-- Detecting CXX compiler ABI info                                                                                                                                          -- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped                                                                                                                   -- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/include (found version "1.67.0")                                                                                                                       -- Configuring done
-- Generating done                                                                                                                                                          -- Build files have been written to: /home/user/projects/github/cpp-cryptlite/build

 Wed 21 Apr - 12:31  ~/projects/github/cpp-cryptlite/build   origin ☊ master ✔ 
 user@localhost  make
Scanning dependencies of target gtest-main
[  8%] Building CXX object gtest/CMakeFiles/gtest-main.dir/src/gtest_main.cc.o
[ 16%] Linking CXX static library libgtest-main.a
[ 16%] Built target gtest-main
Scanning dependencies of target gtest
[ 25%] Building CXX object gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 33%] Linking CXX static library libgtest.a
[ 33%] Built target gtest
Scanning dependencies of target sha256Test
[ 41%] Building CXX object tests/CMakeFiles/sha256Test.dir/sha256Test.cpp.o
[ 50%] Linking CXX executable sha256Test
/usr/bin/ld: ../gtest/libgtest.a(gtest-all.cc.o): in function `testing::internal::UnitTestImpl::~UnitTestImpl()':
gtest-all.cc:(.text+0x3734): undefined reference to `pthread_getspecific'
/usr/bin/ld: gtest-all.cc:(.text+0x374f): undefined reference to `pthread_key_delete'
/usr/bin/ld: gtest-all.cc:(.text+0x39ad): undefined reference to `pthread_getspecific'
/usr/bin/ld: gtest-all.cc:(.text+0x39c5): undefined reference to `pthread_key_delete'
/usr/bin/ld: ../gtest/libgtest.a(gtest-all.cc.o): in function `testing::internal::UnitTestImpl::UnitTestImpl(testing::UnitTest*)':
gtest-all.cc:(.text+0xfc47): undefined reference to `pthread_key_create'
/usr/bin/ld: gtest-all.cc:(.text+0xfde7): undefined reference to `pthread_key_create'
/usr/bin/ld: ../gtest/libgtest.a(gtest-all.cc.o): in function `testing::internal::ThreadLocal<testing::TestPartResultReporterInterface*>::~ThreadLocal()':
gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED2Ev[_ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED
5Ev]+0xc): undefined reference to `pthread_getspecific'
/usr/bin/ld: gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED2Ev[_ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporte
rInterfaceEED5Ev]+0x21): undefined reference to `pthread_key_delete'
/usr/bin/ld: ../gtest/libgtest.a(gtest-all.cc.o): in function `testing::internal::ThreadLocal<std::vector<testing::internal::TraceInfo, std::allocator<testing::internal::Tr
aceInfo> > >::~ThreadLocal()':
gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED2Ev[_ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED5Ev]+0xe):
 undefined reference to `pthread_getspecific'
/usr/bin/ld: gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED2Ev[_ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_E
EED5Ev]+0x25): undefined reference to `pthread_key_delete'
/usr/bin/ld: ../gtest/libgtest.a(gtest-all.cc.o): in function `testing::internal::ThreadLocal<std::vector<testing::internal::TraceInfo, std::allocator<testing::internal::Tr
aceInfo> > >::GetOrCreateValue() const':
gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESa
IS3_EEE16GetOrCreateValueEv]+0x14): undefined reference to `pthread_getspecific'
/usr/bin/ld: gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalISt6vectorINS0_
9TraceInfoESaIS3_EEE16GetOrCreateValueEv]+0x163): undefined reference to `pthread_setspecific'
/usr/bin/ld: ../gtest/libgtest.a(gtest-all.cc.o): in function `testing::internal::ThreadLocal<testing::TestPartResultReporterInterface*>::GetOrCreateValue() const':
gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultRe
porterInterfaceEE16GetOrCreateValueEv]+0xc): undefined reference to `pthread_getspecific'
/usr/bin/ld: gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_31Tes
tPartResultReporterInterfaceEE16GetOrCreateValueEv]+0x56): undefined reference to `pthread_setspecific'
collect2: error: ld returned 1 exit status
make[2]: *** [tests/CMakeFiles/sha256Test.dir/build.make:105: tests/sha256Test] Error 1
make[1]: *** [CMakeFiles/Makefile2:239: tests/CMakeFiles/sha256Test.dir/all] Error 2
make: *** [Makefile:160: all] Error 2
{code}

What should I do to solve it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.