| 89 | } |
| 90 | |
| 91 | std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend) { |
| 92 | |
| 93 | std::string ret; |
| 94 | unsigned char digits[256]; |
| 95 | |
| 96 | // Skip leading zeroes |
| 97 | while (pbegin != pend && *pbegin == 0) { |
| 98 | ret.push_back('1'); |
| 99 | pbegin++; |
| 100 | } |
| 101 | int length = (int)(pend - pbegin); |
| 102 | |
| 103 | int digitslen = 1; |
| 104 | digits[0]=0; |
| 105 | for(int i = 0; i < length; i++) { |
| 106 | uint32_t carry = pbegin[i]; |
| 107 | for(int j = 0; j < digitslen; j++) { |
| 108 | carry += (uint32_t)(digits[j]) << 8; |
| 109 | digits[j] = (unsigned char)(carry % 58); |
| 110 | carry /= 58; |
| 111 | } |
| 112 | while(carry > 0) { |
| 113 | digits[digitslen++] = (unsigned char)(carry % 58); |
| 114 | carry /= 58; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | // reverse |
| 119 | for(int i = 0; i < digitslen; i++) |
| 120 | ret.push_back(pszBase58[digits[digitslen - 1 - i]]); |
| 121 | |
| 122 | return ret; |
| 123 | |
| 124 | } |
| 125 | |
| 126 | std::string EncodeBase58(const std::vector<unsigned char>& vch) |
| 127 | { |
no outgoing calls
no test coverage detected