apoc.hashing.fingerprinting

Function APOC Core

apoc.hashing.fingerprinting(object Any, config Map<String, Any>) - calculates a MD5 checksum over a node or a relationship (identical entities share the same checksum). Unlike apoc.hashing.fingerprint(), this function supports a number of config parameters. Unsuitable for cryptographic use-cases.

Signature

apoc.hashing.fingerprinting(some object :: ANY?, conf = {} :: MAP?) :: (STRING?)

Input parameters

Name Type Default

object

ANY?

null

conf

MAP?

{}

Config parameters

Table 1. apoc.hashing.fingerprinting configuration params
name type default description

digestAlgorithm

String

"MD5"

The algorithm used to compute the fingerprint. Supported values are: MD5, SHA-1, SHA-256

strategy

String

"LAZY"

Defines the filtering behaviour of nodes/relationships. Supported values are:

  • LAZY - does not include properties.

  • EAGER - includes all non-filtered properties.

nodeAllowMap

Map<String, List<String>>

{}

Node label name mapped to a list of allowed properties for that label.

nodeDisallowMap

Map<String, List<String>>

[]

Node label name mapped to a list of properties to ignore for that label.

relAllowMap

Map<String, List<String>>

{}

Relationship type name mapped to a list of allowed properties for that type.

relDisallowMap

Map<String, List<String>>

[]

Relationship type name mapped to a list of properties to ignore for that type.

mapAllowList

List<String>

[]

A list of allowed keys when the object being hashed is a map.

mapDisallowList

List<String>

[]

A list of keys to ignore when the object being hashed is a map.

allNodesAllowList

List<String>

[]

A list of globally allowed node properties

allNodesDisallowList

List<String>

[]

A list of globally ignored node properties.

allRelsAllowList

List<String>

[]

A list of globally allowed relationship properties.

allRelsDisallowList

List<String>

[]

A list of globally ignored relationship properties.

Usage Examples

The examples in this section are based on the following sample graph:

MERGE (joe:Person {name: "Joe"})
MERGE (ryan:Person {name: "Ryan"})
MERGE (ryan)-[:FOLLOWS {since: datetime("2020-11-04")}]->(joe);

The following generates the fingerprint for Ryan:

MATCH (person:Person {name: "Ryan"})
RETURN apoc.hashing.fingerprinting(person) AS output;
Table 2. Results
output

"D41D8CD98F00B204E9800998ECF8427E"

The following generates the fingerprint for Ryan, using the EAGER strategy, which includes node properties:

MATCH (person:Person {name: "Ryan"})
RETURN apoc.hashing.fingerprinting(person, {
  strategy: "EAGER"
}) AS output;
Table 3. Results
output

"81C99DD6C9382C4E01A1873F9E818CE0"

The following generates the fingerprint for Ryan, excluding the name property:

MATCH (person:Person {name: "Ryan"})
RETURN apoc.hashing.fingerprinting(person, {
  allNodesDisallowList: ["name"]
}) AS output;
Table 4. Results
output

"D41D8CD98F00B204E9800998ECF8427E"

The following generates the fingerprint for Ryan, using the SHA-256 algorithm:

MATCH (person:Person {name: "Ryan"})
RETURN apoc.hashing.fingerprinting(person, {
  digestAlgorithm: "SHA-256"
}) AS output;
Table 5. Results
output

"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"

If we want less control over the generation of the fingerprint, see apoc.hashing.fingerprint.