/*
 * ToDo
 * ====
 * Different key sizes -> different block sizes...
 *
 */

   import java.security.MessageDigest;

/**
 * Checksum - Tim Tyler 2001.
 * 
 * Checksum - hash a message to produce a key.<P>
 * This code has been placed in the public domain.<P>
 * You can do what you like with it.<P>
 * Note that this code comes with no warranty.<P>
 *
 */
   class Checksum {
      // static int size_of_key;
   
   /**
    * Produce a 128-bit SHA-1 checksum of the file from the 16th byte onwards...
    * 
    */
      static byte[] checksum(TerminatedFile tf, int start_offset) {
         byte[] digest;
         MessageDigest md;
      
         try {
            md = MessageDigest.getInstance("SHA");
            md.update(tf.data, start_offset, tf.length - start_offset);
            return md.digest();
         } 
            catch (Exception e) {
               Log.log("Error while hashing:");
               e.printStackTrace(Log.getPrintStream());
            }
      
         return null;
      }
   
   
      public static void main(String args[]) {
         BIAESFrEnd.main(args);
      }
   
   }