ipfs-chromium
Loading...
Searching...
No Matches
multi_hash.h
1#ifndef IPFS_MULTI_HASH_H_
2#define IPFS_MULTI_HASH_H_
3
4#include <vocab/byte_view.h>
5
6#include <vector>
7
8namespace ipfs {
9enum class HashType { INVALID = -1, IDENTITY = 0, SHA2_256 = 0X12 };
10constexpr std::uint16_t MaximumHashLength = 127;
11
12HashType Validate(HashType);
13std::string_view GetName(HashType);
17class MultiHash {
18 public:
19 MultiHash() = default;
20 explicit MultiHash(ByteView);
21 explicit MultiHash(HashType, ByteView digest);
22
23 bool ReadPrefix(ByteView&);
24
25 bool valid() const;
26 HashType type() const { return type_; }
27 ByteView digest() const { return hash_; }
28 bool operator==(MultiHash const&) const = default;
29
30 private:
31 HashType type_ = HashType::INVALID;
32 std::vector<Byte> hash_;
33};
34} // namespace ipfs
35
36#endif // IPFS_MULTI_HASH_H_
Definition multi_hash.h:17