Witam dopiero zaczynam programowac w Javie, i mam jak to zawsze na poczatku problem z opanowaniem funkcji w tym jezyku.Otoz probuje napisac maly programik do hashowania linijek w pliku txt. W necie znalazlem intersujace mnie kody, ale chcialby je troche pozmieniac. Umiescic klase File Read w sekcji class MD5 Generator i miejsce String text = "Hello World"; W ten sposb moim laickim mysleniem to chyba jakos bedzie dzaialalo tak jak chce. Tylko nie wiem jak to ma odpalic.
Pozdrawiam
package Generator;
import java.math.BigInteger;
import java.security.MessageDigest;
public class MD5Generator {
public static void main(String args[]) throws Exception {
String text = "Hello World";
MessageDigest m = MessageDigest.getInstance("MD5");
m.update(text.getBytes(), 0, text.length());
String digest = new BigInteger(1, m.digest()).toString(16);
System.out.println("MD5: " + digest);
}
}
import java.io.*;
class FileRead
{
public static void main(String args[])
{
try{
FileInputStream fstream = new FileInputStream("C:\\p.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
System.out.println (strLine);
}
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}