Skip to content

C++ implementation (header-only) of SHA-256

License

Notifications You must be signed in to change notification settings

MilkyTAsefa/hash_sha256

 
 

Repository files navigation

hash_sha256

Build Status Issues CodeQL Codacy Badge Quality Gate Status code coverage Boost Software License 1.0

A simple implementation of SHA-256 in C++ (header-only). This implementation uses little endian byte order.

Using the hash_sha256

  • The following program shows a test example
// Create an object of hash_sha256
hash_sha256 hash1;

// Original message
const std::array<std::uint8_t, 3U> msg1 = {'a', 'b', 'c' };

// Initialize hash
hash1.sha256_init();

// Update the hash with given data
hash1.sha256_update(msg1.data(), msg1.size());

// Get hash result
sha256_output_type hash_result1 = hash1.sha256_final();

Testing, continuous integration and quality

Testing and continuous integration runs on GitHub Actions. Various OS/compiler combinations are used including GCC/clang/MSVC.

Code coverage uses GCC/gcov/lcov and has a quality-gate with comparison/baseline-check provided by third-party Codecov.

Additional quality checks are performed on pull-request and merge to master using modern third party open-source services. These include LGTM and CodeSonar.

Algorithm efficiency

The following picture shows the real-time measurement of the sha256 benchmark run on 32-bit microcontrollers (ARM Cortex™ M4) of the NUCLEO-F446RE board. The hash calculation takes about 32 µs

sha_256

References

Algorithm specification can be found here:

About

C++ implementation (header-only) of SHA-256

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 87.0%
  • Python 13.0%