Hello,
I'm trying to create a checksum in an
applet and send it to the
servlet where it can be compared.
I'm having this code:
//mail is a MimeMessage object: a mail containing a bit of text and an attachment and a signature
URLConnection connection = getConnectionToServlet();
OutputStream emptyOutput = new OutputStream(){
public void write(int b) throws IOException {
}
};
CheckedOutputStream checkedOut = new CheckedOutputStream(emptyOutput,new CRC32());
mail.writeTo(checkedOut);
System.out.println("mail checksum over empty-output: "+checkedOut.getChecksum().getValue());
out = connection.getOutputStream();
CheckedOutputStream checkedOut2 = new CheckedOutputStream(out,new CRC32());
mail.writeTo(checkedOut2);
System.out.println("mail checksum over real-output: "+checkedOut2.getChecksum().getValue());
and it gives me the following output:
applet checksum over empty-output: 472918629
applet checksum over real-output: 2979688346
How can this be possible?? I would expect the checkedOutputStream would just take bytes, update checksum and at send bytes to the wrapped stream?
Can someone explain how this is possible?
Also,
when I put that code in a loop, I get results as:
applet checksum over empty-output: 472918629
applet checksum over real-output: 2979688346
applet checksum over empty-output: 1455969375
applet checksum over real-output: 2957360115
applet checksum over empty-output: 1607214671
applet checksum over real-output: 1607214671
So sometimes the checksum is the same... I do not understand.
Thanks.
Tim