MCPcopy Create free account
hub / github.com/bcndev/bytecoin / encode

Function encode

src/common/Base58.cpp:184–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182} // namespace
183
184std::string encode(const BinaryArray &data) {
185 size_t full_block_count = data.size() / full_block_size;
186 size_t last_block_size = data.size() % full_block_size;
187 size_t res_size = full_block_count * full_encoded_block_size + encoded_block_sizes[last_block_size];
188
189 std::string res(res_size, '*'); // All asterisks must be replaced after encoding
190 for (size_t i = 0; i < full_block_count; ++i) {
191 encode_block(data.data() + i * full_block_size, full_block_size, &res[i * full_encoded_block_size]);
192 }
193 if (last_block_size > 0) {
194 encode_block(data.data() + full_block_count * full_block_size, last_block_size,
195 &res[full_block_count * full_encoded_block_size]);
196 }
197 return res;
198}
199
200bool decode(const std::string &enc, BinaryArray *data) {
201 size_t full_block_count = enc.size() / full_encoded_block_size;

Callers 4

encode_addrFunction · 0.70
interactive_testFunction · 0.70
mainFunction · 0.50
main_appFunction · 0.50

Calls 3

encode_blockFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected