华容道高性能计算引擎
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.
 
 
 
 
 

40 lines
939 B

#pragma once
/// Provides XXH3 and MD5 hash calculation support. The former is far ahead in
/// speed, but the latter is more of a commemorative significance.
#include "md5.h"
#include "xxh3.h"
#include <vector>
#include <cstdint>
namespace hash {
inline std::string md5(const void *data, const uint64_t size) {
return md5::MD5::Hash(data, size);
}
inline uint64_t xxh3(const void *data, const uint64_t size) {
return XXH_INLINE_XXH3_64bits(data, size);
}
inline std::string md5(const std::string_view &data) {
return md5(data.data(), data.size());
}
inline uint64_t xxh3(const std::string_view &data) {
return xxh3(data.data(), data.size());
}
template <typename T>
std::string md5(const std::vector<T> &data) {
return md5(data.data(), data.size() * sizeof(T));
}
template <typename T>
uint64_t xxh3(const std::vector<T> &data) {
return xxh3(data.data(), data.size() * sizeof(T));
}
} // namespace hash