core.crypto
Class Digest

java.lang.Object
  extended by core.crypto.Digest

public class Digest
extends Object

A static class providing all message digest operations

  Copyright (c) 2006 Sebastian Erdweg
  Copyright (c) 2006 Dominik Schulz
  Copyright (c) 2006 Florian Lindner
  Copyright (c) 2006 Betim Berjani
  
  This file is part of FlexiCrypt.

  FlexiCrypt is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  FlexiCrypt is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with FlexiCrypt; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  

Author:
Dominik, Sebastian

Method Summary
static boolean digestsEqual(byte[] b1, byte[] b2)
          Deprecated. 
static byte[] getDigest(byte[] input, String algorithm)
           
static byte[] getDigest(File inputFile, MessageDigest algorithm)
           
static byte[] getDigest(InputStream fis, MessageDigest algorithm, long fileLength)
          Creates a MessageDigest on the FileInputStream
static byte[] getDigest(InputStream fis, String algorithm, long inputLength)
          Creates a MessageDigest on the FileInputStream
static byte[] getDigest(String input, String algorithm)
           
static int getDigestLength(MessageDigest algorithm)
           
static int getDigestLength(String algorithm)
           
static Set<String> getValidServices()
          Creates a set of valid digest algorithms
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDigestLength

public static int getDigestLength(String algorithm)
                           throws NoSuchAlgorithmException
Throws:
NoSuchAlgorithmException

getDigestLength

public static int getDigestLength(MessageDigest algorithm)

getDigest

public static byte[] getDigest(InputStream fis,
                               MessageDigest algorithm,
                               long fileLength)
                        throws InterruptedException,
                               NoSuchAlgorithmException,
                               InvalidAlgorithmParameterException,
                               IOException
Creates a MessageDigest on the FileInputStream

Parameters:
fis -
algorithm -
fileLength -
Returns:
The MessageDigest
Throws:
InterruptedException
NoSuchAlgorithmException
InvalidAlgorithmParameterException
IOException

getDigest

public static byte[] getDigest(InputStream fis,
                               String algorithm,
                               long inputLength)
                        throws NoSuchAlgorithmException,
                               InvalidAlgorithmParameterException,
                               InterruptedException,
                               IOException
Creates a MessageDigest on the FileInputStream

Parameters:
fis -
algorithm -
inputLength -
Returns:
The Message Digest
Throws:
NoSuchAlgorithmException
InvalidAlgorithmParameterException
InterruptedException
IOException

getDigest

public static byte[] getDigest(File inputFile,
                               MessageDigest algorithm)
                        throws InterruptedException,
                               NoSuchAlgorithmException,
                               InvalidAlgorithmParameterException,
                               IOException
Throws:
InterruptedException
NoSuchAlgorithmException
InvalidAlgorithmParameterException
IOException

getDigest

public static byte[] getDigest(byte[] input,
                               String algorithm)
                        throws NoSuchAlgorithmException,
                               InvalidAlgorithmParameterException,
                               InterruptedException,
                               IOException
Throws:
NoSuchAlgorithmException
InvalidAlgorithmParameterException
InterruptedException
IOException

getDigest

public static byte[] getDigest(String input,
                               String algorithm)
                        throws NoSuchAlgorithmException,
                               InvalidAlgorithmParameterException,
                               InterruptedException,
                               IOException
Throws:
NoSuchAlgorithmException
InvalidAlgorithmParameterException
InterruptedException
IOException

getValidServices

public static Set<String> getValidServices()
Creates a set of valid digest algorithms

Returns:
a set of valid digest algorithms

digestsEqual

@Deprecated
public static boolean digestsEqual(byte[] b1,
                                              byte[] b2)
Deprecated. 

Use ByteArray.equals(b1, b2) instead helper function to compare to byte arrays

Parameters:
b1 - a byte array
b2 - antoher byte array
Returns:
whether the arrays are the same