import java.net.*;
import java.io.*;
import java.security.*;
import javax.crypto.*;
public class messagedigestsend {
public static void main( String [ ] args) throws Exception{
byte ttl= (byte) 0;
try
{
MulticastSocket mSocket = new MulticastSocket();
MulticastSocket mSocket2 = new MulticastSocket();
InetAddress mAddr = InetAddress.getByName("224.0.0.1");
String sendString = "M";
byte[] plainText = sendString.getBytes("UTF8");
//
// get a message digest object using the MD5 algorithm
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
//
// print out the provider used
System.out.println( "\n" + messageDigest.getProvider().getInfo() );
//
// calculate the digest and print it out
messageDigest.update( plainText);
String messagetransfer = new String( messageDigest.digest(), "UTF8");
byte[] digestText = messagetransfer.getBytes("UTF8");
System.out.println( "\nPlain text sent is: "+sendString);
System.out.println( "\nDigest message sent is: "+messagetransfer);
//byte [ ] buffer = sendString.getBytes();
DatagramPacket dp = new DatagramPacket(plainText, plainText.length, mAddr, 5000);
mSocket.send(dp);
DatagramPacket dp2 = new DatagramPacket(digestText, digestText.length, mAddr, 5001);
mSocket2.send(dp2);
}
catch (SocketException se)
{
System.out.println("Socket Exception : " + se);
}
catch (IOException e)
{
System.out.println("Exception : " + e);
}
}//end of main
}// end of class definition
This is a program that could digest the M letter with MD5 algorithm.What is i want to digest the text from the text file .Something regarding to the FileInputStream but i have no idea how to embed into it .Please ,show it to me