Equity
Bitcoin Protocol Library
Utility.h
1 #pragma once
2 
3 #include <crypto/Sha256.h>
4 #include <cstdint>
5 #include <string>
6 #include <vector>
7 
8 namespace Utility
9 {
10 
12 std::string toHex(std::vector<uint8_t> const & v);
13 
15 std::string toHex(uint8_t const * v, size_t length);
16 
18 template <size_t N>
19 std::string toHex(std::array<uint8_t, N> const & a)
20 {
21  return toHex(a.data(), a.size());
22 }
23 
25 std::vector<uint8_t> fromHex(std::string const & x);
26 
28 std::vector<uint8_t> fromHex(char const * x, size_t length);
29 
31 std::string toHexR(std::vector<uint8_t> const & v);
32 
34 std::string toHexR(uint8_t const * v, size_t length);
35 
37 std::vector<uint8_t> fromHexR(std::string const & x);
38 
40 std::vector<uint8_t> fromHexR(char const * x, size_t length);
41 
43 template <size_t N>
44 std::string toHexR(std::array<uint8_t, N> const & a)
45 {
46  return toHexR(a.data(), a.size());
47 }
48 
49 // Shortens a string replacing the middle with ...
50 std::string shorten(std::string const & in, size_t size = 11);
51 
52 } // namespace Utility
Definition: Endian.h:7