util_module

The util module offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations.

TraitValue
Module typeutil
ImplementationC++
Graph directiondirected/undirected
Edge weightsweighted/unweighted
Parallelismsequential

Procedures

md5()

The procedure gets the string representation of every element in the input list or string, concatenates it into a single string, and returns the md5 hash of that string.

The format of string representations can be seen by checking ToString in C++ API documentation for desired type or Value.

Input:

  • values: List[Any], Any ➡ THe input list containing elements which can be any of Memgraph's data types. User can also pass any type by itself.

Output:

  • result: string ➡ The resulting md5 hash returned as string.

Usage:

The hash provided in this documentation will be different from the user's hash for the same input unless the node has the same ID because Node.ToString() uses the node's ID in string formation, so different IDs equal different strings, hence, different hashes:

CREATE (d:Dog);
MATCH (d:Dog)
CALL util_module.md5([d, "string", 50])
YIELD result
RETURN result;

Result:

+-----------------------------------+
| result                            |
+-----------------------------------+
| 47e656a5f446fc21316e97df90e8ae33  |
+-----------------------------------+

Functions

md5()

The function gets the string representation of every element in the input list or string, concatenates it into a single string, and returns the md5 hash of that string. Does the same computation as the md5() procedure but can be called as a function

The format of string representations can be seen by checking ToString in C++ API documentation for desired type or Value.

Input:

  • values: List[Any], Any ➡ The input list containing elements which can be any of Memgraph's data types. User can also pass any type by itself.

Output:

  • result: string ➡ The resulting md5 hash returned as a string.

Usage:

The hash provided in this documentation will be different from the user's hash for the same input unless the node has the same ID because Node.ToString() uses the node's ID in string formation, so different IDs equal different strings, hence, different hashes:

CREATE (d:Dog);
MATCH (d:Dog)
RETURN util_module.md5([d, "string", 50]) AS result

Result:

+-----------------------------------+
| result                            |
+-----------------------------------+
| 47e656a5f446fc21316e97df90e8ae33  |
+-----------------------------------+