You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sha256.h 820B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) 2014-2016 The Starwels developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #ifndef STARWELS_CRYPTO_SHA256_H
  5. #define STARWELS_CRYPTO_SHA256_H
  6. #include <stdint.h>
  7. #include <stdlib.h>
  8. #include <string>
  9. /** A hasher class for SHA-256. */
  10. class CSHA256
  11. {
  12. private:
  13. uint32_t s[8];
  14. unsigned char buf[64];
  15. uint64_t bytes;
  16. public:
  17. static const size_t OUTPUT_SIZE = 32;
  18. CSHA256();
  19. CSHA256& Write(const unsigned char* data, size_t len);
  20. void Finalize(unsigned char hash[OUTPUT_SIZE]);
  21. CSHA256& Reset();
  22. };
  23. /** Autodetect the best available SHA256 implementation.
  24. * Returns the name of the implementation.
  25. */
  26. std::string SHA256AutoDetect();
  27. #endif // STARWELS_CRYPTO_SHA256_H