Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

lockblox/multihash

Open more actions menu

Repository files navigation

multihash

Build Status Build Status Coverage Status

multihash implementation in c++.

Multihash is delivered as

  1. A library: libmultihash
  2. An executable: bin/multihash

Build

Building with Docker

The supplied dockerfile produces a reproducable build image which can be used to compile the source:

docker build -t lockblox/multihash multihash
docker run -it --rm -v multihash:/root/src lockblox/multihash 

Building Manually

Installing Prerequisites

Multihash requires some dependencies to be met before building, which are provided via vcpkg as follows:

 git clone https://github.com/lockblox/vcpkg.git \
 cd vcpkg \
 ./bootstrap-vcpkg.sh \
 ./vcpkg integrate install \
 ./vcpkg install gtest cryptopp ms-gsl varint

Building with CMake

Multihash uses cmake for builds. In order for cmake to find the required dependencies, the -DCMAKE_TOOLCHAIN_FILE option should be supplied, for example:

 cmake -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake" ../multihash
 cmake --build .

Usage

Algorithm

At the lowest level, there is the abstract type multihash::algorithm.

A multihash::algorithm defines the steps required to compute a hash from input data.

multihash::algorithm instances are created by a factory and each factory is registered under a unique hash code identifier.

auto code = multihash::code::sha3_256;
auto algorithm = multihash::algorithm::create(code);
auto buffer = std::string{"hello, world"};
algorithm->update(buffer);
auto result = std::string(256, '=');
algorithm->digest(result);

Function

A multihash::function is a hash functor which operates on iterator pairs.

auto multihash = multihash::function(code)(input.begin(), input.end());

Multihash

A multihash::multihash combines the hash code and multihash in a binary payload.

auto code = multihash.code();
auto multihash = multihash.multihash();

License

multihash is released under the MIT License.

About

C++ Implementation of Multihash

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.