Hi,
My AES key has some characters like '$' etc. So the normal methods to convert string to byte and byte to string didn't seem to work because they use this set of characters.
public static String strHexVal = "0123456789abcdef";
So I have started using CharsetEncoder, ByteBuffer and CharBuffer and now I am able to encode and decode this sample string successfully.
ByteBuffer bbuf = encoder.encode(CharBuffer.wrap( "Te$$$st" ));
CharBuffer cbuf = decoder.decode(bbuf);
But when I use this code to read an actual key from a JCEKS keystore
Key key = store.getKey( "aesfileencryption", getPassword() );
CharBuffer cbuf = decoder.decode( key.getEncoded() );
I don't get the correct key.
What am I missing ?
Thanks,
Mohan