## 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 anonymises a text or number. Anonymisation is executed such that when the same original value is anonymised within the same session, the anonymised value will be identical. The anonymised value also uniquely matches the original value. With no access to the anonymisation map however, the original value can however not be calculated from the anonymised value. In mathematics, the anonymisation function is a bijection: each element of the original set is paired with exactly one element of the anonymised set, and each element of the anonymised set is paired with exactly one element of the original set. Parameters: - Value (`ANY`): a text or number to be obfuscated. - Maximum length (optional, `int32`): maximum length in digits for numbers or characters for text of anonymised value. `null` means no restriction on maximum length (default). - Mapping (optional, `varchar2`): 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 anonymisation maps are available: - `DEFAULT`: the default mapping algorithm. - `IVE-GL-JOURNAL-DESCRIPTION`: general ledger journal descriptions. No preferred anonymisations, 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 anonymisations, 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 anonymisation maps are typically used to replace name and address information by values resembling actual names and addresses. Returns: Anonymised value in data type of the value provided. ### Data Dictionary The data dictionary contains the anonymisation maps used so far in the session and their corresponding values: - [[Invantive-SYSTEMANONYMIZATIONPREDEFINEDMAPS]]: full list of predefined anonymisation maps, as given above. - [[Invantive-SYSTEMANONYMIZATIONMAPS]]: anonymisation maps used in this session. - [[Invantive-SYSTEMANONYMIZATIONMAPVALUES]]: original and mapped values used in this session. Typically stored after anonymisation 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 ```