cluster5.shared.utils
Class HashCalculator
java.lang.Object
cluster5.shared.utils.HashCalculator
public class HashCalculator
- extends java.lang.Object
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HashCalculator
public HashCalculator()
addListener
public void addListener(HashCalculatorProgressListener listener)
- Adds a listener which will be updated on the progress of hashing a file/stream.
- Parameters:
listener
- a listener to be added
removeListener
public void removeListener(HashCalculator listener)
- Parameters:
listener
- a listener to be removed
getHash
public java.lang.String getHash(java.lang.String message,
HashCalculator.Algorithms algorithm)
- Calculates hash of the message using the specified algorithm.
- Parameters:
message
- algorithm
-
- Returns:
- hash of the message or null if something went wrong
getHash
public java.lang.String getHash(java.io.InputStream inputStream,
HashCalculator.Algorithms algorithm)
- Calculates hash of the data passed in the input stream using the specified algorithm.
Does not notify registered listeners on hash calculation progress.
- Parameters:
inputStream
- algorithm
-
- Returns:
- hash of the data or null if something went wrong.
getHash
public java.lang.String getHash(java.io.File file,
HashCalculator.Algorithms algorithm)
- Calculates hash of the specified file using the algorithm. While the hash is
calculated, the registered listeners are notified on the progress.
- Parameters:
file
- algorithm
-
- Returns:
- hash of the file or null if something went wrong.
main
public static void main(java.lang.String[] args)
throws java.io.IOException
- Parameters:
args
-
- Throws:
java.io.IOException