summaryrefslogtreecommitdiff
path: root/src/sha1.cc
blob: 5d20ca90e379473a0824701e8edcae1858856ce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "sha1.hh"

namespace sha1 {

std::array<uint8_t, 20> hash(std::span<char const> input) {
  // std::string and std::string_view -> std::span includes null terminating
  // byte.
  if (!input.empty() && input.back() == '\0') {
    return hash(std::span{reinterpret_cast<uint8_t const*>(input.data()),
                          input.size() - 1});
  }
  return hash(
      std::span{reinterpret_cast<uint8_t const*>(input.data()), input.size()});
}

}  // namespace sha1