|
Apr
15
|
The BigDecimal class makes this really easy as it has a method toByteArray() that returns exactly what we need. Just need to create a BigDecimal and call the method.
byte[] bytes = new BigInteger(hexString, 16).toByteArray();

May 20th, 2009 at 3:50 am
Hi objects,
Not sure if I could seek advice here…I’ve tried this code and it works
However, the byte array generated is not the same as the original byte. I mean I used
key = KeyGenerator.getInstance(“DES”).generateKey();
byte[] mybytekey = key.getEncoded();
I’ve got random key(Secret key type) and byte array. At later stage, triggered by some action, I will need to use ‘mybytekey’ to generate the ‘key’ for decryption purpose. At this stage, I am stuck when i store a hexString and try to get it back via byte[] bytes = new BigInteger(hexString, 16).toByteArray();
the byte array values is different…
any ideas how i should fix this? Thanks in advance.
May 22nd, 2009 at 12:19 am
Chien,
Where are you getting the hexString from?