2

I have a byte Array which I want to Base58 encode. But I only want to encode the first 12 and the last 12 letter. So I need to convert the byte array into a String split it and convert it back into a byte array to encode it in Base58? Maybe there is a better way?

Kindly Regards!

SamuelTJackson
  • 1,357
  • 3
  • 19
  • 40

1 Answers1

2

You can use Arrays.copyOfRange:

byte[] first12 = Arrays.copyOfRange(byteArray, 0, 11);
byte[] last12 = Arrays.copyOfRange(byteArray, byteArray.length - 13, byteArray.length - 1);
Joe Attardi
  • 4,381
  • 3
  • 39
  • 41
  • Hey, If I encode my original byte array with Hex.encodeHexString(originalByteArray) and then I look at Hex.encodeHexString(first12 + last12) I don't get the last and the first 12 letters. I get the first 22 and the last 24. – SamuelTJackson May 12 '16 at 20:19