2

I have a string like this:

"12"

And I need to convert it to a hex value like this:

0x12

I have a byte array like this

// 00 20 22 80 08 24 pi nn ff ff ff ff ff 
byte VerifyingAPDU[] = { (byte)0x00,(byte)0x20,(byte)0x00,(byte)0x80,(byte)0x08,(byte)0x24,
                     (byte)0x12,(byte)0x34, //pi nn
                     (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff };
Now i want to replace pi nn with user entered value in Eidter (EditText). how to do this ?

For example user entered 1111 in editer i have to replace Ox12 --> 0x11 and 0x34-->0x11.

RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166

1 Answers1

11

This should be

Integer.toHexString(Integer.parseInt(String)); 

Ref : Convert to/from hexadecimal

Jignesh Mayani
  • 6,937
  • 1
  • 20
  • 36
Pankaj Kumar
  • 81,967
  • 29
  • 167
  • 186