DES Program Update/Help

Hi,

I'm trying to accomplish the following:

-Generate a DES key

-Store it in a file

-Use the DES key to encrypt my message and send it over socket s to a server

I've made a lot of progress, but I'm not sure what's missing, as this is all basically new to me. If anyone can examine it and provide some help, I'd really appreciate it.

Thanks,

James

import java.io.*;

import java.net.*;

import java.security.*;

import javax.crypto.*;

publicclass CipherClient

{

publicstaticvoid main(String[] args)throws Exception

{

String message ="Hello, how are you John?";

String host ="xxxxx";//bleeped out for privacy reasons

int port = xxxx;//bleeped out for privacy reasons

Socket s =new Socket(host, port);

//DES Key Generation

KeyGenerator generator= KeyGenerator.getInstance("DES");

generator.init(new SecureRandom());

key=generator.generateKey();

//Storage of DES Key to File

ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream("des.key"));

out.writeObject(key);

out.close();

//usage of ObjectOutputStream to communicate with the server

ObjectOutputStream outSocket =new ObjectOutputStream(s.getOutputStream());

//Encrypt the message above using the key and send it over socket s to the server

Cipher cipher=Cipher.getInstance("DES/ECB/PKCS5Padding");

cipher.init(Cipher.ENCRYPT_MODE, key);

//Passing the encrypted message over socket s to the server

CipherOutputStream cipherOut =new CipherOutputStream(sSocket, cipher);

}

}

[2683 byte] By [Ohio2005a] at [2007-10-2 6:14:25]
# 1

//Passing the encrypted message over socket s to the server

CipherOutputStream cipherOut = new CipherOutputStream(s.getOutputStream(), cipher);

//usage of ObjectOutputStream to communicate with the server

ObjectOutputStream outSocket = new ObjectOutputStream(cipherOut);

sabre150a at 2007-7-16 13:15:52 > top of Java-index,Security,Cryptography...