## Syntax ```mermaid %%{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}%% flowchart LR Start((START)) --> ANONYMIZE[ANONYMIZE]:::quoted ANONYMIZE --> End((END)) ``` ## Purpose The `ANONYMIZE` SQL function anonymizes a text or number. Anonymization is executed such that when the same original value is anonymized within the same session, the anonymized value will be identical. The anonymized value also uniquely matches the original value. With no access to the anonymization map however, the original value can however not be calculated from the anonymized value. In mathematics, the anonymization function is a bijection: each element of the original set is paired with exactly one element of the anonymized set, and each element of the anonymized set is paired with exactly one element of the original set. Parameters: - Value: A text or number to be obfuscated. - Maximum length (optional): Maximum length in digits for numbers or characters for text of anonymized value. Null means no restriction on maximum length (default). - Mapping (optional): algorithm to use. The default algorithm is `DEFAULT` which maps text values to a range of hexadecimal characters and numbers to a range of numbers. Alternative mappings are described below. The following anonymization maps are available: - `DEFAULT`: the default mapping algorithm. - `IVE-GL-JOURNAL-DESCRIPTION`: general ledger journal descriptions. No preferred anonymizations, leave familiar and non-confidential descriptions in original state such as "Bank" and "ING bank". - `IVE-GL-ACCOUNT-DESCRIPTION`: general ledger account descriptions. No preferred anonymizations, leave familiar and non-confidential descriptions in original state such as "Abonnementen" and "Af te dragen BTW". - `IVE-PSN-FIRST-NAME`: person first names. Prefer readable alternative first names randomly chosen from a set of over 1.200. When the set is exhausted, the default mapping algorithm is applied. - `IVE-PSN-LAST-NAME`: person last names. Prefer readable alternative last names randomly chosen from a set of over 2.600. When the set is exhausted, the default mapping algorithm is applied. - `IVE-ADS-CITY-NAME`: address city names. Prefer readable alternative city names randomly chosen from a set of over 2.500. When the set is exhausted, the default mapping algorithm is applied. - `IVE-ADS-STREET-NAME`: address street names. Prefer readable alternative street names randomly chosen from a set of over 2.300. When the set is exhausted, the default mapping algorithm is applied. - `IVE-EMAIL-ADDRESS`: email addresses. Prefer readable alternative email addresses randomly chosen from a set of over 800. When the set is exhausted, the default mapping algorithm is applied. - `IVE-ADS-POSTAL-CODE`: postal codes. Prefer readable alternative postal codes randomly chosen from a set of over 800. When the set is exhausted, the default mapping algorithm is applied. The non-default anonymization maps are typically used to replace name and address information by values resembling actual names and addresses. Returns: Anonymized value. ### Data Dictionary The data dictionary contains the anonymization maps used so far in the session and their corresponding values: - [[Invantive-SYSTEMANONYMIZATIONPREDEFINEDMAPS]]: full list of predefined anonymization maps, as given above. - [[Invantive-SYSTEMANONYMIZATIONMAPS]]: anonymization maps used in this session. - [[Invantive-SYSTEMANONYMIZATIONMAPVALUES]]: original and mapped values used in this session. Typically stored after anonymization in a secure location to allow retrieval of the original information. ## Examples `ANONYMIZE` the same first name using the `DEFAULT` anonymization map: ```sql select anonymize('John') c1 , anonymize('John') c2 -------------------------------- -------------------------------- 6086BBF5FAF604C5C710E28AA7BE15A0 6086BBF5FAF604C5C710E28AA7BE15A0 ``` `ANONYMIZE` the same first name using the `IVE-PSN-FIRST-NAME` anonymization map for first names: ```sql select anonymize('John', null, 'IVE-PSN-FIRST-NAME') c1 , anonymize('John', null, 'IVE-PSN-FIRST-NAME') c2 -------------------------------- -------------------------------- Frits Frits ```