MCPcopy Index your code
hub / github.com/ccxt/ccxt / binaryToBase58

Method binaryToBase58

java/lib/src/main/java/io/github/ccxt/base/Encode.java:226–244  ·  view source on GitHub ↗
(Object buff2)

Source from the content-addressed store, hash-verified

224 }
225
226 public static String binaryToBase58(Object buff2) {
227 byte[] buff = (byte[]) buff2;
228 if (buff.length == 0) return "";
229 int zeros = 0;
230 while (zeros < buff.length && buff[zeros] == 0) zeros++;
231 // prepend a 0 byte so BigInteger treats input as unsigned
232 byte[] unsigned = new byte[buff.length + 1];
233 System.arraycopy(buff, 0, unsigned, 1, buff.length);
234 BigInteger n = new BigInteger(unsigned);
235 BigInteger base = BigInteger.valueOf(58);
236 StringBuilder sb = new StringBuilder();
237 while (n.signum() > 0) {
238 BigInteger[] qr = n.divideAndRemainder(base);
239 sb.insert(0, B58_ALPHABET.charAt(qr[1].intValue()));
240 n = qr[0];
241 }
242 for (int i = 0; i < zeros; i++) sb.insert(0, '1');
243 return sb.toString();
244 }
245
246 public static String intToBase16(Object number) {
247 long n = Long.parseLong(String.valueOf(number));

Callers 1

signMessageMethod · 0.45

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected