Class MappingHasher
java.lang.Object
org.incenp.obofoundry.sssom.MappingHasher
Creates deterministic hash values from mappings.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance that will produce the standard hash defined by the SSSOM specification.MappingHasher(HashType type) Creates a new instance that will produce the requested type of hash. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]fnv64(byte[] input) Generates a FNV64 hash.Hashes the given mapping.static StringtoHexadecimal(byte[] digest) Encodes a buffer into its hexadecimal representation.static StringtoHexadecimal(byte[] digest, boolean lower) Encodes a buffer into its hexadecimal representation, optional in lowercase.static StringtoZBase32(byte[] digest) Encodes a buffer into its Z-Base32 string representation.
-
Constructor Details
-
MappingHasher
public MappingHasher()Creates a new instance that will produce the standard hash defined by the SSSOM specification. -
MappingHasher
Creates a new instance that will produce the requested type of hash.- Parameters:
type- The type of hash to produce.
-
-
Method Details
-
hash
-
fnv64
public static byte[] fnv64(byte[] input) Generates a FNV64 hash.This method implements the 64-bit variant of the FNV-1a hash function as defined in RFC 9923.
- Parameters:
input- The data to hash.- Returns:
- The resulting hash value, as an array of bytes in little endian order.
-
toZBase32
Encodes a buffer into its Z-Base32 string representation.This method implements the Z-Base32 encoding as defined in RFC 6189 ยง5.1.6 and human-oriented base32 encoding.
- Parameters:
digest- The input buffer to encode.- Returns:
- The Z-Base32-encoded string representation of the input buffer.
-
toHexadecimal
-
toHexadecimal
Encodes a buffer into its hexadecimal representation, optional in lowercase.- Parameters:
digest- The input buffer to encode.lower- Iftrue, lowercase characters are used.- Returns:
- The hexadecimal representation of the input buffer.
-