insert()
Encrypt a plaintext value(s), create a token(s), insert into the token vault(s), and return the token(s). If the plaintext value passed in has already been tokenized, this method simply returns the token value.
Note
This method is overloaded to handle customData, value arrays, customData arrays, and saveExceptions (Smart Check feature).
Syntax
public string insert (string value, string table, int format, bool luhnCheck)
public string insert (string value, string table, int format, bool luhnCheck, string tokenProperty, string customTokenProperty)
public string[] insert (string[] values, string table, int format, bool luhnCheck)
public string[] insert (string[] values, string table, int format, bool luhnCheck, string tokenProperty, string customTokenProperty)
public string[] insert (string[] values, string table, int format, bool luhnCheck, string[] tokenProperty, string[] customTokenProperty)
public string insert (string value, string customData, string table, int format, bool luhnCheck)
public string insert (string value, string customData, string table, int format, bool luhnCheck, string tokenProperty, string customTokenProperty)
public string[] insert (string[] values, string[] customData, string table, int format, bool luhnCheck)
public string[] insert (string[] values, string[] customData, string table, int format, bool luhnCheck, string tokenProperty, string customTokenProperty)
public string[] insert (string[] values, string[] customData, string table, int format, bool luhnCheck, string[] tokenProperty, string[] customTokenProperty)
public TmResult insert (string[] values, string[] customData, string table, int format, bool luhnCheck, bool saveExceptions)
public TmResult insert (string[] values, string[] customData, string table, int format, bool luhnCheck, bool saveExceptions, string tokenProperty, string customTokenProperty)
public TmResult insert (string[] values, string[] customData, string table, int format, bool luhnCheck, bool saveExceptions, string[] tokenProperty, string[] customTokenProperty)
public string[][] insert (string[][] values, string[] table, int[] format, bool luhnCheck, string[] tokenProperty, string[] customTokenProperty)
Note
If your application calls insert(), get(), or deleteValue() within a loop, make sure that it starts the token service outside of the loop. See Sample: Starting the Token Service Outside of the Loop.
Request Parameters
Parameters | Data Types | Descriptions |
---|---|---|
values | string, string[] or string[][] | data to be tokenized. Input data can be no longer than 256 characters. Note: String[][] values are used with String[] table. Each array specifies the data to be tokenized using the corresponding token vault specified in array of table. |
customData | string or string[] | customer-specific data. |
table or tables | string or string[] | The token vault or token vaults. The table(s) must be in CAPITAL LETTERS. |
format or formats | int or int[] | One of the following token formats or a format created using createNewFormat(). |
luhnCheck | boolean | boolean indicates if the value must pass a Luhn check (true) or if there is no requirement (false). Token formats created using the createNewFormat() method may have one of three luhnCheck rules. The rules are must fail test, no requirement, and must pass test. |
saveExceptions | boolean | When set to true, the Smart Check functionality is enabled. |
tokenProperty | string or string[] | A string of 16 bit alphanumeric string that provides the priority and status of the token or array of strings. Refer to Features for more details. |
customTokenProperty | string or string[] | A string of up to 255 characters including special characters or array of strings. |
Available formats are listed below. You must prepend “TokenService.” to the format name, as shown below.
TokenService.RANDOM_TOKEN
TokenService.RANDOM_ALPHANUMERIC_TOKEN
TokenService.ALPHANUMERIC_TOKEN
TokenService.SEQUENTIAL_TOKEN
TokenService.LAST_FOUR_TOKEN
TokenService.FIRST_SIX_TOKEN
TokenService.FIRST_TWO_LAST_FOUR_TOKEN
TokenService.FIRST_SIX_LAST_FOUR_TOKEN
TokenService.FIXED_NINETEEN_TOKEN
TokenService.FIXED_TWENTY_LAST_FOUR_TOKEN
TokenService.EMAIL_ADDRESS_TOKEN
TokenService.DATE_MMDDYYYY_TOKEN
TokenService.DATE_DDMMYYYY_TOKEN
TokenService.DATE_YYYYMMDD_TOKEN
TokenService.FIRST_SIX_LAST_FOUR_FAIL_LUHN_TOKEN
TokenService.FIXED_FIRST_TWO_LAST_FOUR_FAIL_LUHN_TOKEN
TokenService.SHA2_256_BASE16_TOKEN
TokenService.SHA2_384_BASE16_TOKEN
TokenService.SHA2_512_BASE16_TOKEN
TokenService.SHA2_256_ BASE64_TOKEN
TokenService.SHA2_384_ BASE64_TOKEN
TokenService.SHA2_512_ BASE64_TOKEN
For more information about these formats, see Token Formats.
The priority of the luhnCheck boolean in insert() and the luhnCheck integer in createNewFormat() vary depending on their values, as shown in the following figure:
Returned Values
String, string array, or two dimensional string arrays of token(s) created for the input value(s).
Exception
Passes an exception if:
table is missing
format is invalid
value is null or contains anything other than digits, white spaces, or dashes
value and customData arrays are not the same size
customData element is too long.
Example
insert("1234567890123456", "CREDIT_CARD_NUMBERS", TokenService.LAST_FOUR_TOKEN, true).`
The method does the following:
Searches the key table for the keys used by the token vault.
Requests the encryption and hmac keys from the Key Manager.
Uses the encryption and hmac key to create the ciphertext and mac value.
Generates the token according to the token format rules and the luhn check setting.
Inserts the ciphertext, mac value, and token into the token vault.
Returns the token to the calling application.