Hi George,

key.getEncoded() returns a byte array that is a textual representation of the external key in Hex.

Just Stringify the byte array and set it to the 'encryptedKey' JDBC connection URL attribute - that should work.



On Mon, Nov 30, 2009 at 10:45 PM, George H <george.dma@gmail.com> wrote:

I am trying to create an embedded derby db using an encryption key that I generate before hand. I've read the derby v10.5.3.0 ref guide and the developer guide and I still have one question that lingers in my mind.

In the JDBC url where I have to specify the encryption key attribute how do we get the key in string form? In the docs they use examples (Dev guide page 114 (PDF)) where the key looks like a letters and numbers and in most cases just numbers.

Now when I generate my key like

KeyGenerator keyGen = KeyGenerator.getInstance("AES")
SecretKey key = keyGen.generateKey();

I only have the method   key.getEncoded() that I can use which returns an array of bytes. I wonder how I can give this key to derby in the jdbc url ? Do I have to convert the byte array to a HEX string ? or to decimals? I don't know. If someone could help me out on this specific part it would be great.

George H