generate key for DES

Hi,

I'm tring to use the Cipher.init(...) method, but I have to introduce the DES secret key first. I am confused about the concepts of generating a key and providing one in the correct format. In my situation, I want to provide the secret key and then init the cipher object with it... My key is an 8-byte array.. But the cipher method expects an object of type 'Key', which i don't know how to manipulate..

thanks in advance,

fbm

[460 byte] By [ferbara] at [2007-10-3 6:00:45]
# 1

Given the key bytes then

byte[] keyBytes = the 8 bytes of your key

SecretKey key = new SecretKeySpec(keyBytes, "DES");

P.S In case you are wondering, SecretKeySpec implements the SecretKey interface.

sabre150a at 2007-7-15 0:42:39 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks a lot! that was very helpful..fbm
ferbara at 2007-7-15 0:42:39 > top of Java-index,Java Essentials,Java Programming...