org.helidb.lang.hasher
Class StringToBigIntegerHasher
java.lang.Object
org.helidb.lang.hasher.AbstractMessageDigestStringHasher<BigInteger>
org.helidb.lang.hasher.StringToBigIntegerHasher
- All Implemented Interfaces:
- Hasher<String,BigInteger>
public class StringToBigIntegerHasher
- extends AbstractMessageDigestStringHasher<BigInteger>
This Hasher
uses a MessageDigest
object with a configurable
hash algorithm to produce a hash of a configurable length 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 as long as this object is configured to
expect it to be. The hash bytes are extracted from the hash produced by the
MessageDigest
by taking its first bytes up to the configured length.
- Since:
- 1.0
- Author:
- Karl Gustafsson
- See Also:
StringToLongHasher
- In_jar:
- helidb-core
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StringToBigIntegerHasher
public StringToBigIntegerHasher(int numLength)
throws IllegalArgumentException
- Throws:
IllegalArgumentException
StringToBigIntegerHasher
public StringToBigIntegerHasher(int numLength,
int noOfBitsInMostSignificantByte)
throws IllegalArgumentException
- Throws:
IllegalArgumentException
StringToBigIntegerHasher
public StringToBigIntegerHasher(int numLength,
int noOfBitsInMostSignificantByte,
String hashAlgorithm,
String provider,
Charset cs)
throws IllegalArgumentException
- Throws:
IllegalArgumentException
toBytes
public byte[] toBytes(BigInteger l)
- Description copied from interface:
Hasher
- Serialize the hash to a byte array.
For a given Hasher
object, the byte arrays returned by this
method must always be of the same size.
- Parameters:
l
- The hash to serialize.
- Returns:
- The serialized hash.
fromBytes
public BigInteger fromBytes(byte[] barr)
- Description copied from interface:
Hasher
- Interpret the serialized hash value.
- Parameters:
barr
- The serialized hash value.
- Returns:
- The hash value.