Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

base58.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <bench/bench.h>
6 
7 #include <validation.h>
8 #include <base58.h>
9 
10 #include <array>
11 #include <vector>
12 #include <string>
13 
14 
15 static void Base58Encode(benchmark::State& state)
16 {
17  static const std::array<unsigned char, 32> buff = {
18  {
19  17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147,
20  227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90,
21  200, 24
22  }
23  };
24  while (state.KeepRunning()) {
25  EncodeBase58(buff.data(), buff.data() + buff.size());
26  }
27 }
28 
29 
31 {
32  static const std::array<unsigned char, 32> buff = {
33  {
34  17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147,
35  227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90,
36  200, 24
37  }
38  };
39  std::vector<unsigned char> vch;
40  vch.assign(buff.begin(), buff.end());
41  while (state.KeepRunning()) {
42  EncodeBase58Check(vch);
43  }
44 }
45 
46 
47 static void Base58Decode(benchmark::State& state)
48 {
49  const char* addr = "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem";
50  std::vector<unsigned char> vch;
51  while (state.KeepRunning()) {
52  DecodeBase58(addr, vch);
53  }
54 }
55 
56 
bool DecodeBase58(const char *psz, std::vector< unsigned char > &vch)
Decode a base58-encoded string (psz) into a byte vector (vchRet).
Definition: base58.cpp:21
std::string EncodeBase58(const unsigned char *pbegin, const unsigned char *pend)
Why base-58 instead of standard base-64 encoding?
Definition: base58.cpp:71
bool KeepRunning()
Definition: bench.cpp:39
static void Base58CheckEncode(benchmark::State &state)
Definition: base58.cpp:30
BENCHMARK(Base58Encode)
static void Base58Encode(benchmark::State &state)
Definition: base58.cpp:15
std::string EncodeBase58Check(const std::vector< unsigned char > &vchIn)
Encode a byte vector into a base58-encoded string, including checksum.
Definition: base58.cpp:121
static void Base58Decode(benchmark::State &state)
Definition: base58.cpp:47
Released under the MIT license