summaryrefslogtreecommitdiff
path: root/src/sha1.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sha1.cc')
-rw-r--r--src/sha1.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/sha1.cc b/src/sha1.cc
new file mode 100644
index 0000000..5d20ca9
--- /dev/null
+++ b/src/sha1.cc
@@ -0,0 +1,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