import java.security.*;
import java.io.*;
import java.util.*;
public class Hash {
System.
out.
print("Inizio calcolo hash");
while(digestIn.read() != -1);
byte[] digest = md.digest();
System.
out.
println(". Calcolo terminato!!");
return digest;
}
byte[] digest = calcolaHash(fileIn);
int b = 0;
while((b = fis.read()) != -1) {
baos.write(b);
}
byte[] hashSaved = baos.toByteArray();
if(Arrays.
equals(digest, hashSaved
)) {
System.
out.
println("L'impronta combacia");
} else {
System.
out.
println("L'impronta non combacia");
}
}
if(args.length < 2 || (args[0].equals("-v") && args.length != 3)) {
System.
out.
println("Usage: Hash -c || -v fileInput [se -v] fileImpronta\n" +
"opzioni: -c calcola l'hash e lo salva in fileOutput\n" +
"opzioni: -v verifica l'hash di fileOutput con fileImpronta\n" +
"ad esempio: Hash -c file.txt\n" +
" Hash -v file.txt hashFile.txt\n");
}
if(args[0].equals("-c")) {
fos.write(calcolaHash(args[1]));
fos.close();
} else if(args[0].equals("-v")) {
verificaHash(args[1], args[2]);
}
}
}