All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class is.hi.logir.cryptonite.Fingerprint

java.lang.Object
   |
   +----is.hi.logir.cryptonite.Cryptonite
           |
           +----is.hi.logir.cryptonite.Fingerprint

public class Fingerprint
extends Cryptonite
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 another buffer that gives the same 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 FingerprintState, so you should look there for information about a particular hash function.

You should be very careful about saving fingerprints. If a fingerprint is not calculated at run-time, then it should not be trusted, since it may have been tampered with in storage or transit.

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:
FingerprintState, Signature

Constructor Index

 o Fingerprint(String)
Called by Cryptonite.fromString(String) .
 o Fingerprint(String, byte[])
Creates a new Fingerprint object with the given algorithm name and the hash value from fp.
 o Fingerprint(String, byte[], int)
Creates a new Fingerprint object with the given algorithm name and the hash value from fp[0..n-1].

Method Index

 o create(byte[], int, int, String)
Create a Fingerprint object for the data in buf[offset..offset+length-1] with the named fingerprint algorithm.
 o create(byte[], String)
Create a Fingerprint object for the data in buf with the named fingerprint algorithm.
 o create(String, String)
Create a Fingerprint object for the string s with the named fingerprint algorithm.
 o equals(Object)
return true if obj is a fingerprint equal to this.
 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 toString()
Return a CDS for this fingerprint.

Constructors

 o Fingerprint
 public Fingerprint(String algorithm,
                    byte fp[],
                    int n)
Creates a new Fingerprint object with the given algorithm name and the hash value from fp[0..n-1].

 o Fingerprint
 public Fingerprint(String algorithm,
                    byte fp[])
Creates a new Fingerprint object with the given algorithm name and the hash value from fp.

 o Fingerprint
 public Fingerprint(String arg) throws InvalidCDSException
Called by Cryptonite.fromString(String) .

Throws: InvalidCDSException
if a FingerprintState object for the named algorithm could not be created.

Methods

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

Throws: InvalidCDSException
if a FingerprintState 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 for the data in buf with the named fingerprint algorithm.

Throws: InvalidCDSException
if a FingerprintState 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 for the string s with the named fingerprint algorithm.

Throws: InvalidCDSException
if a FingerprintState object for the named algorithm could not be created.
 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)
return 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