IntelliJ Java IDE
The moose likes Java in General and the fly likes MD5 checksum, can i do this faster , from a inputstream ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "MD5 checksum, can i do this faster , from a inputstream ?" Watch "MD5 checksum, can i do this faster , from a inputstream ?" New topic
Author

MD5 checksum, can i do this faster , from a inputstream ?

Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 331
I calculate a MD5 checksum, from a inputstream, but with this code i read the 1 mb data to calculate the MD5......

Its not allsays 1 mb, it can be from 50 kb ---> 50 mb

Is there anyone, that knows if i can do this faster.....





Frank
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18365

Don't use buf.length but num. num can be smaller than buf.length if there weren't enough bytes available. This way you may write some garbage of a previous read to the MD5 digest, and your length may be too high.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
 
subject: MD5 checksum, can i do this faster , from a inputstream ?
 
Threads others viewed
The fastet way to stream data to the response in a servlet ?
AES encryption from within a Tomcat web container
Fastest way of calculating MD5
Problem creating the zip file
Fastest way of calculating MD5
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com