Creating a fingerprint
To create a fingerprint object, instantiate the gw.util.fingerprint.FP64 object and pass one of the supported object types to the constructor:
- A
Stringobject:var s = "hello" var f = new FP64(s) - A character array:
var s = "hello" var ca : char[] = {s[0], s[1], s[2], s[3], s[4]} var f = new FP64(ca)An alternative method signature takes extra parameters for start position and length of the series of characters in the array.
- A byte array:
var ba = "hello".Bytes // Or use "hello".getBytes( var f = new FP64(ba)An alternative method signature takes extra parameters for start position and length of the series of bytes in the array.
- A stream object:
var s = "testInputStreamConstructor" new FP64(new ByteArrayInputStream(gw.util.StreamUtil.toBytes(s)))); - An input stream:
var s = "testInputStreamConstructor" new FP64(new StringBuffer(g)); - Another
FP64fingerprint object to duplicate the fingerprint:var s = "hello" var f = new FP64(s) var f2 = new FP64(f)
Generating the fingerprint binary data
To generate output data from a fingerprint, use the FP64 method toBytes(), which returns the value of this fingerprint as a newly allocated array of 8 bytes.
Instead of the no-argument method, you can also use the alternative method signature that takes a byte array buffer into which the method writes the bytes. The buffer must have a length of at least 8 bytes.
Alternatively, you can use a method toHexString(). This method returns the fingerprint as an unsigned integer encoded in base 16 (hexadecimal) and padded with leading zeros to a total length of 16 characters.
Fingerprints as keys in hash maps
Because the FP64 class overrides the Java methods
equals and hashCode, you can use FP64
objects as keys in hash tables. For example, use FP64 values as keys in a
java.util.HashMap instance.
