All Packages Class Hierarchy This Package Previous Next Index
Class IS.hi.logir.cryptonite.Fingerprint
java.lang.Object
|
+----IS.hi.logir.cryptonite.Fingerprint
- public class Fingerprint
- extends Object
- implements Serializable
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. This is why the
private fingerprint field of the Key class is marked as transient and
re-calcualted when the class is deserialized.
- Author:
- Logi Ragnarsson (logir@hi.is)
- See Also:
- FingerprintState, Signature
-
algorithm
- algorithm holds the name of the algorithm
used to create this fingerprint.
-
fp
- fp holds the actual bytes of the fingerprint value.
-
nibble
-
-
Fingerprint(String, byte[])
-
Creates a new Fingerprint object given algorithm name and
the hash value from fp.
-
Fingerprint(String, byte[], int)
-
Creates a new Fingerprint object given algorithm name and
the hash value from fp[0..n-1].
-
equals(Object)
- return true if obj is a fingerprint equal to this.
-
get(String, byte[])
- Creates a fingerprint for the buffer buf using the named
fingerprint-class.
-
getBytes()
- Return an array of the bytes in the fingerprint.
-
getName()
- Return the name of the algorithm used for this hash.
-
hashCode()
-
-
toString()
- Return a string represesntation of this fingerprint.
fp
protected byte fp[]
- fp holds the actual bytes of the fingerprint value.
algorithm
protected String algorithm
- algorithm holds the name of the algorithm
used to create this fingerprint.
nibble
private static char nibble[]
Fingerprint
public Fingerprint(String algorithm,
byte fp[],
int n)
- Creates a new Fingerprint object given algorithm name and
the hash value from fp[0..n-1].
Fingerprint
public Fingerprint(String algorithm,
byte fp[])
- Creates a new Fingerprint object given algorithm name and
the hash value from fp.
get
public static Fingerprint get(String name,
byte buf[]) throws BadFingerprintClassException
- Creates a fingerprint for the buffer buf using the named
fingerprint-class.
A fingerprint class with the specified name must previously have
been registered by calling the registerIncludedClasses method
on the FingerprintState class. This is automatically done for
classes included with cryptonite but any other classes must be
registered manually.
getName
public String getName()
- Return the name of the algorithm used for this hash.
getBytes
public byte[] getBytes()
- Return an array of the bytes in the fingerprint.
equals
public boolean equals(Object obj)
- return true if obj is a fingerprint equal to this.
- Overrides:
- equals in class Object
hashCode
public int hashCode()
- Overrides:
- hashCode in class Object
toString
public String toString()
- Return a string represesntation of this fingerprint.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index