Kagome
Polkadot Runtime Engine in C++17
sha256.cpp
Go to the documentation of this file.
1 
6 #include "crypto/sha/sha256.hpp"
7 
8 #include <openssl/sha.h>
9 
10 namespace kagome::crypto {
11  common::Hash256 sha256(std::string_view input) {
12  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
13  const auto *bytes_ptr = reinterpret_cast<const uint8_t *>(input.data());
14  return sha256(gsl::make_span(bytes_ptr, input.length()));
15  }
16 
17  common::Hash256 sha256(gsl::span<const uint8_t> input) {
18  common::Hash256 out;
19  SHA256_CTX ctx;
20  SHA256_Init(&ctx);
21  SHA256_Update(&ctx, input.data(), input.size());
22  SHA256_Final(out.data(), &ctx);
23  return out;
24  }
25 } // namespace kagome::crypto
gsl::span< const uint8_t > make_span(const rocksdb::Slice &s)
common::Hash256 sha256(std::string_view input)
Definition: sha256.cpp:11