Class DualDigester


  • class DualDigester
    extends java.lang.Object
    Calculates md5 and sha1 digest.

    Todo: Consider using a thread to calculate one of the digests when the files are large; it's fairly slow !

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] buffer  
      private static int BUFSIZE  
      private java.security.MessageDigest md5  
      private java.security.MessageDigest sh1  
    • Constructor Summary

      Constructors 
      Constructor Description
      DualDigester()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void calculate​(java.io.File file)  
      (package private) void calculate​(java.io.InputStream stream)  
      (package private) static java.security.MessageDigest getDigester​(java.lang.String algorithm)  
      java.lang.String getMd5()  
      java.lang.String getSha1()  
      private void update​(java.io.InputStream is)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • md5

        private final java.security.MessageDigest md5
      • sh1

        private final java.security.MessageDigest sh1
      • buffer

        private final byte[] buffer
    • Constructor Detail

      • DualDigester

        DualDigester()
    • Method Detail

      • getDigester

        static java.security.MessageDigest getDigester​(java.lang.String algorithm)
      • calculate

        public void calculate​(java.io.File file)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • calculate

        void calculate​(java.io.InputStream stream)
                throws java.io.IOException
        Throws:
        java.io.IOException
      • getMd5

        public java.lang.String getMd5()
      • getSha1

        public java.lang.String getSha1()
      • update

        private void update​(java.io.InputStream is)
                     throws java.io.IOException
        Throws:
        java.io.IOException