3

I would like to Base58-encode this String:

    56379c7bcd6b41188854e74169f844e8676cf8b8

My current Java code looks like this:

    String test9 = "56379c7bcd6b41188854e74169f844e8676cf8b8";
    byte[] b2 = new BigInteger(test9,16).toByteArray();
    String test8 = Base58.encode(b2);
    System.out.println(test8);

As result I get:

    2CffxtJsCdzJEaHXHjSkvb12p12P

but I should get:

    39YteymR86cG7V3Kijg8Gm2ST1r4nTeM1b

Can someone help me, please?

1
  • @Ryan_McGeary What is the library that you got access to Base58 class? I like to know. Commented Jun 11, 2021 at 19:16

1 Answer 1

4

Your output is correct given the input that you used.

However, If you are expecting to get an output address of 39YteymR86cG7V3Kijg8Gm2ST1r4nTeM1b, it looks like your input is incorrect. It's missing the first byte and the last 4 bytes (encoded as hex):

  Your Input: --56379c7bcd6b41188854e74169f844e8676cf8b8--------
Proper Input: 0556379c7bcd6b41188854e74169f844e8676cf8b86e1b34ba

Try this tool for validating your expectations:

Example Form

3
  • Thanks! From where did you know I need do add 05 and 6e1b34ba?
    – A.c
    Commented Dec 29, 2017 at 18:51
  • I dont know the address before. I only know the String which has then to be base58-encoded to show me the address.
    – A.c
    Commented Dec 29, 2017 at 19:03
  • @A.c From the site that I linked to in my answer. I reversed your expected output. Commented Dec 29, 2017 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.