|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.logi.crypto.Crypto | +--org.logi.crypto.sign.Fingerprint
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 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 hash function used and
fp
the actual fingerprint.
HashState
,
Signature
Fields inherited from class org.logi.crypto.Crypto |
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO |
Constructor Summary | |
Fingerprint(java.lang.String hashFunc,
byte[] fp)
Creates a new Fingerprint object. |
|
Fingerprint(java.lang.String hashFunc,
byte[] fp,
int offset,
int n)
Creates a new Fingerprint object. |
Method Summary | |
static Fingerprint |
create(byte[] buf,
int offset,
int length,
java.lang.String hashFunc)
Create a Fingerprint object. |
static Fingerprint |
create(byte[] buf,
java.lang.String hashFunc)
Create a Fingerprint object. |
static Fingerprint |
create(java.lang.String s,
java.lang.String hashFunc)
Create a Fingerprint object. |
boolean |
equals(java.lang.Object obj)
Test for equality with another object. |
byte[] |
getBytes()
Return an array of the bytes in the fingerprint. |
java.lang.String |
getHashFunc()
Return the name of the hash function used for this fingerprint. |
int |
hashCode()
Return a hash-code based on the bytes of the fingerprint and the hash function name. |
static Fingerprint |
parseCDS(java.lang.String[] param)
Used by Crypto.fromString when parsing a CDS. |
void |
prettyPrint(java.io.PrintWriter out,
int ind,
int rec)
Print this object to out, indented with ind tabs, going down at most rec levels of recursion. |
java.lang.String |
toString()
Return a CDS for this fingerprint. |
Methods inherited from class org.logi.crypto.Crypto |
binString, binString, ensureArrayLength, ensureArrayLength, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, prettyPrint, readBlock, readInt, trimArrayLength, trimArrayLength, trimLeadingZeroes, writeBytes, writeBytes, writeInt |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Fingerprint(java.lang.String hashFunc, byte[] fp, int offset, int n)
fp[offset..offset+n-1]
which was generated with the
named hash function.public Fingerprint(java.lang.String hashFunc, byte[] fp)
fp
which was generated with the named hash function.Method Detail |
public static Fingerprint create(byte[] buf, int offset, int length, java.lang.String hashFunc) throws InvalidCDSException
buf[offset..offset+length-1]
calculated with
the named fingerprint hash function.InvalidCDSException
- if a HashState object for the
named hash function could not be created.public static Fingerprint create(byte[] buf, java.lang.String hashFunc) throws InvalidCDSException
buf
calculated with the named
fingerprint hash function.InvalidCDSException
- if a HashState object for the
named hash function could not be created.public static Fingerprint create(java.lang.String s, java.lang.String hashFunc) throws InvalidCDSException
InvalidCDSException
- if a HashState object for the
named hash function could not be created.public static Fingerprint parseCDS(java.lang.String[] param) throws InvalidCDSException
A valid CDS can be created by calling the toString() method.
InvalidCDSException
- if the CDS is malformed.Crypto.fromString(String)
public java.lang.String getHashFunc()
public byte[] getBytes()
public boolean equals(java.lang.Object obj)
obj
is a Fingerprint equal to this
.equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public void prettyPrint(java.io.PrintWriter out, int ind, int rec) throws java.io.IOException
prettyPrint
in class Crypto
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |