Skip to main content

Connecting and Testing

Once the functions are installed, point the database at TAKAKRYPT and try each function. These steps are the same for MySQL and PostgreSQL.


1. Register the Database​

Before a database can encrypt, tokenize, or mask, it has to be registered once and approved by an administrator. Run this on the database itself, with a label the administrator will recognize, such as pg-hris-prod:

SELECT tdp_enroll('<GATEWAY_URL>', '<ACCESS_TOKEN>', '<USER_KEY>', '<TENANT>', '<LABEL>');

It returns a message saying the database was enrolled and is pending approval. Then ask an administrator to approve it on the Database Plugin page of the TAKAKRYPT console. Each approved database uses one seat of your TDB license.

Until it is approved, tdp_configure is refused with a message such as Instance "..." is waiting for administrator approval. Once it is approved, run tdp_configure as shown below. If tdp_configure was already refused, run it again.


2. Connect to TAKAKRYPT​

Run tdp_configure with the connection details from your TAKAKRYPT account:

SELECT tdp_configure(
'<GATEWAY_URL>',
'<ACCESS_TOKEN>',
'<USER_KEY>',
'<TENANT>'
);
ParameterDescription
GATEWAY_URLThe address of the TAKAKRYPT Gateway
ACCESS_TOKENThe access token
USER_KEYThe account's user key
TENANTThe tenant name

If the connection works, the function returns a message saying that TDP was configured successfully.

warning

These values are part of the query, so they can end up in query logs, client history, and saved scripts. Keep them out of shared scripts, and create new ones if they are ever exposed.

On MySQL, tdp_configure applies to the whole server. Running it from any session replaces the credentials and clears the key cache for every session. On PostgreSQL, the settings apply per session.


3. Test the Functions​

Replace <CONFIG_ID> with the ID of the configuration the function should use.

Tokenization

SELECT tdp_tokenize('name', '<CONFIG_ID>');

Detokenization

Tokenize and detokenize in one query:

SELECT tdp_detokenize(tdp_tokenize('name', '<CONFIG_ID>'), '<CONFIG_ID>');

Or detokenize a token you already have:

SELECT tdp_detokenize('<TOKEN>', '<CONFIG_ID>');

Encryption

SELECT tdp_encrypt('Hello World', '<CONFIG_ID>');

Decryption

SELECT tdp_decrypt(tdp_encrypt('Hello World', '<CONFIG_ID>'), '<CONFIG_ID>');

Data masking

SELECT tdp_mask('4111111111111111', '<CONFIG_ID>');

If something doesn't work, check that the server can reach the TAKAKRYPT Gateway over HTTPS on port 443, as listed in the Prerequisites.