Q:

How to get File both MD5 and SHA1 checksum at the same time when upload a new file?

I am working on a storage system. Users upload files to the server. 
On the server side, I want to implement a program to get the checksums of the file using both MD5 and SHA1. 
I know how to calculate checksums using DigestInputStream functions, but it seems only supports one method (either MD5 or SHA1) a time. 
How can I calculate both MD5 and SHA1 a the same time when dealing with the upload stream in JAVA? 
Thanks guys

A:

Use two MessageDigest instances (one for MD5 and one for SHA1) and feed the bytes you read into both.

