Can anyone please help me with the following? I would like to be able to generat
ID: 3634605 • Letter: C
Question
Can anyone please help me with the following? I would like to be able
to generate a DES key, store it in a file, and use the key to encrypt
my message and send it to my friend's server. I've started the
program, but am not sure where else to go with it. Any help is greatly
appreciated.
code:
import java.io.*;
import java.net.*;
import java.security.*;
import javax.crypto.*;
public class Cipher
{
public static void main(String[] args) throws Exception
{
String message = "Hi John, here is the first message.";
String host = "xxx.xxx.xxx";
int port = 7999;
Socket s = new Socket(host, port);
//Help here
// DES key.
//Storage of DES key
// Encrypt the message using the key and send it to the
server
}
}
Explanation / Answer
Taken from Wikipedia: "DES is now considered to be insecure for many applications. This is chiefly due to the 56-bit key size being too small; in January, 1999, distributed.net and the Electronic Frontier Foundation collaborated to publicly break a DES key in 22 hours and 15 minutes (see chronology). There are also some analytical results which demonstrate theoretical weaknesses in the cipher, although they are infeasible to mount in practice. The algorithm is believed to be practically secure in the form of Triple DES, although there are theoretical attacks. In recent years, the cipher has been superseded by the Advanced Encryption Standard (AES). Furthermore, DES has been withdrawn as a standard by the National Institute of Standards and Technology (formerly the National Bureau of Standards)" (http://en.wikipedia.org/wiki/Data_Encryption_Standard).
DES isn't very secure, I would recommend using the Advanced Encryption Standard (AES) (http://en.wikipedia.org/wiki/Advanced_Encryption_Standard). RSA (http://en.wikipedia.org/wiki/RSA) with a large key (at least a hundred bits) is also a good choice for sending secure messages and might be easier for you to code.
Anyways, the next step for your program is to write methods to generate a key, and encrypt a message using the key.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.