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
-
Fingerprint(String)
- Called by
Cryptonite.fromString(String)
.
-
Fingerprint(String, byte[])
-
Creates a new Fingerprint object with the given algorithm name and
the hash value from
fp
.
-
Fingerprint(String, byte[], int)
-
Creates a new Fingerprint object with the given algorithm name and
the hash value from
fp[0..n-1]
.
-
create(byte[], int, int, String)
- Create a Fingerprint object for the data in
buf[offset..offset+length-1] with the named
fingerprint algorithm.
-
create(byte[], String)
- Create a Fingerprint object for the data in buf
with the named fingerprint algorithm.
-
create(String, String)
- Create a Fingerprint object for the string s
with the named fingerprint algorithm.
-
equals(Object)
- return true if
obj
is a fingerprint equal to this
.
-
getBytes()
- Return an array of the bytes in the fingerprint.
-
getName()
- Return the name of the algorithm used for this fingerprint.
-
hashCode()
- Return a hash-code based on the bytes of the
fingerprint and the algorithm name.
-
toString()
- Return a CDS for this fingerprint.
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]
.
Fingerprint
public Fingerprint(String algorithm,
byte fp[])
- Creates a new Fingerprint object with the given algorithm name and
the hash value from
fp
.
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.
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.
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.
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.
getName
public String getName()
- Return the name of the algorithm used for this fingerprint.
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()
- Return a hash-code based on the bytes of the
fingerprint and the algorithm name.
- Overrides:
- hashCode in class Object
toString
public String toString()
- Return a CDS for this fingerprint.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index