All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class is.logi.crypto.hash.Fingerprint

java.lang.Object
   |
   +----is.logi.crypto.Crypto
           |
           +----is.logi.crypto.hash.Fingerprint

public class Fingerprint
extends Crypto
This class is used to hold a fingerprint of a particular data buffer. The idea is to calculate a fingerprint in such a way that it is extremely difficult to create a buffer that gives a particular fingerprint. If that buffer also has to match some other criteria, such as being a valid text file in a particular language, then it becomes next to impossible.

All this depends on the hash function used to create the fingerprint being a good one. Fingerprints are created by the various subclasses of HashState, so you should look there for information about a particular hash function.

The CDS for a Fingerprint object is Fingerprint(NAME,FP) where NAME is the name of the algorithm used and FP the actual fingerprint.

Author:
Logi Ragnarsson (logir@hi.is)
See Also:
HashState, Signature

Constructor Index

 o Fingerprint(String, byte[], int, int)
Creates a new Fingerprint object.

Method Index

 o create(byte[], int, int, String)
Create a Fingerprint object.
 o create(byte[], String)
Create a Fingerprint object.
 o create(String, String)
Create a Fingerprint object.
 o equals(Object)
Test for equality with another object.
 o getBytes()
Return an array of the bytes in the fingerprint.
 o getName()
Return the name of the algorithm used for this fingerprint.
 o hashCode()
Return a hash-code based on the bytes of the fingerprint and the algorithm name.
 o parseCDS(String)
If "Fingerprint( key )" is a valid CDS for a Fingerprint, then Fingerprint.parseCDS(key) will return the described Fingerprint object.
 o toString()
Return a CDS for this fingerprint.

Constructors

 o Fingerprint
 public Fingerprint(String algorithm,
                    byte fp[],
                    int offset,
                    int n)
Creates a new Fingerprint object. It contains the hash value from fp[offset..offset+n-1] which was generated with the named algorithm.

Methods

 o create
 public static Fingerprint create(byte buf[],
                                  int offset,
                                  int length,
                                  String algorithm) throws InvalidCDSException
Create a Fingerprint object. It will contain a fingerprint for the data in buf[offset..offset+length-1] calculated with the named fingerprint algorithm.

Throws: InvalidCDSException
if a HashState object for the named algorithm could not be created.
 o create
 public static Fingerprint create(byte buf[],
                                  String algorithm) throws InvalidCDSException
Create a Fingerprint object. It will contain a fingerprint for the data in buf calculated with the named fingerprint algorithm.

Throws: InvalidCDSException
if a HashState object for the named algorithm could not be created.
 o create
 public static Fingerprint create(String s,
                                  String algorithm) throws InvalidCDSException
Create a Fingerprint object. It will contain a fingerprint for the string s calculated with the named fingerprint algorithm.

Throws: InvalidCDSException
if a HashState object for the named algorithm could not be created.
 o parseCDS
 public static Fingerprint parseCDS(String arg) throws InvalidCDSException
If "Fingerprint( key )" is a valid CDS for a Fingerprint, then Fingerprint.parseCDS(key) will return the described Fingerprint object.

A valid CDS can be created by calling the Fingerprint.toString() method.

Throws: InvalidCDSException
if the CDS is malformed.
See Also:
fromString
 o getName
 public String getName()
Return the name of the algorithm used for this fingerprint.

 o getBytes
 public byte[] getBytes()
Return an array of the bytes in the fingerprint.

 o equals
 public boolean equals(Object obj)
Test for equality with another object. Returns true if obj is a Fingerprint equal to this.

Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Return a hash-code based on the bytes of the fingerprint and the algorithm name.

Overrides:
hashCode in class Object
 o toString
 public String toString()
Return a CDS for this fingerprint.

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index