|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.helidb.lang.hasher.AbstractMessageDigestStringHasher<Long>
org.helidb.lang.hasher.StringToLongHasher
public class StringToLongHasher
This Hasher
uses a MessageDigest
object with a configurable
hash algorithm to produce an eight bytes long hash from a String
. It
does not support null
values.
Any MessageDigest
function may be used for creating the hash, as long
as the hash it produces is at least eight bytes long. The eight bytes are
extracted from the hash produced by the MessageDigest
by taking its
first eight bytes.
Instead of instantiating this class with the no-arguments constructor, the
singleton instance INSTANCE
may be used.
StringToBigIntegerHasher
Field Summary | |
---|---|
static StringToLongHasher |
INSTANCE
The singleton instance. |
Fields inherited from class org.helidb.lang.hasher.AbstractMessageDigestStringHasher |
---|
DEFAULT_ALGORITHM |
Constructor Summary | |
---|---|
StringToLongHasher()
Create an instance of the hasher. |
|
StringToLongHasher(int noOfBitsInMostSignificantByte)
Create an instance of the hasher that uses a bit mask for the most significant byte when creating a hash. |
|
StringToLongHasher(String hashAlgorithm,
int noOfBitsInMostSignificantByte,
String provider,
Charset cs)
Create a hasher. |
Method Summary | |
---|---|
Long |
fromBytes(byte[] barr)
Interpret the serialized hash value. |
byte[] |
toBytes(Long l)
Serialize the hash to a byte array. |
Methods inherited from class org.helidb.lang.hasher.AbstractMessageDigestStringHasher |
---|
assertNoMaskedBitsSet, createDigest, getHashLength, hash, isPreservingValues |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final StringToLongHasher INSTANCE
StringToLongHasher()
.
Constructor Detail |
---|
public StringToLongHasher()
Charset
is the platform's default charset.
Instead of creating an object using this constructor, the singleton
instance INSTANCE
may be used.
public StringToLongHasher(int noOfBitsInMostSignificantByte) throws IllegalArgumentException
Charset
is the platform's default charset.
noOfBitsInMostSignificantByte
- The number of bits to keep in the
most significant byte. The bits kept are the least significant bits. If
this is set to 7, the most significant bit is discarded. If set to 6, the
two most significant bits are discarded, etc.
IllegalArgumentException
- If the number of bits to keep is not
between 0 and 8 (inclusive).public StringToLongHasher(String hashAlgorithm, int noOfBitsInMostSignificantByte, String provider, Charset cs) throws IllegalArgumentException
hashAlgorithm
- The name of the hash algorithm.noOfBitsInMostSignificantByte
- The number of bits to keep in the
most significant byte. The bits kept are the least significant bits. If
this is set to 7, the most significant bit is discarded. If set to 6, the
two most significant bits are discarded, etc.provider
- The name of the security provider. Set to null
to
use the JVM's default provider.cs
- The charset that the String
:s to hash are encoded in.
Set to null
to use the JVM's default charset.
IllegalArgumentException
- If the number of bits to keep is not
between 0 and 8 (inclusive).Method Detail |
---|
public byte[] toBytes(Long l)
Hasher
For a given Hasher
object, the byte arrays returned by this
method must always be of the same size.
l
- The hash to serialize.
public Long fromBytes(byte[] barr)
Hasher
barr
- The serialized hash value.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |