get()
get() gets the plaintext value associated with a token or an array of tokens.
Note
This method is overloaded to handle customData, token arrays, and customData arrays. Also, the plaintext for token generated using insertIrreversibleToken() method will not be returned, instead it will return the string value “Irreversible Token”.
Syntax
public string get(string token, string table, int format)
public string[] get(string[] token, string table, int format)
public string get(string token, string customData, string table, int format)
public string[] get(string[] token, string[] customData, string table,int format)
Note
If your application calls insert(), get(), or deleteValue() within a loop, initialize tokenservice only once even if using the APIs in the loop. See Sample: Starting the Token Service Outside of the Loop.
Request Parameters
Parameters | Data Types | Descriptions |
---|---|---|
token | string or string[] | A token corresponds to an encrypted value, or an array of tokens. |
customData | string or string[] | Customer-specific data. Note: For My SQL, if the customData parameter is null or empty, then the get() API returns results for all customData values in token vault. |
table | string | This is the Token Vault name and it must be in CAPITAL LETTERS. |
format | integer | The format of the returned value. Use one of the following options to set the format of the returned value: • 0 - 0 corresponds to MaskingFormat.SHOW_ALL. It shows all characters of plaintext value. • 1 - 1 corresponds to MaskingFormat.SHOW_FIRST_SIX. It shows only the first six characters of the plaintext value and masks the remaining characters. For example, a 16-digit credit card number will be masked as 123456XXXXXXXXXX. • 2 - 2 corresponds to MaskingFormat.SHOW_FIRST_TWO_LAST_FOUR. It shows only the first two and last four characters of the plaintext value and masks the remaining characters. For example, a 16-digit credit card number will be masked as 12XXXXXXXXXX3456. • 3 - 3 corresponds to MaskingFormat.SHOW_FIRST_SIX_LAST_FOUR. It shows only the first six and last four characters of the plaintext value and masks the remaining characters. For example, a 16-digit credit card number will be masked as 123456XXXXXX1234. • 6 - 6 corresponds to MaskingFormat.SHOW_LAST_FOUR or TokenService.MASK_TOKEN. It shows only the last four characters of the plaintext value and masks the remaining characters. For example, a 16-digit credit card number will be masked as XXXXXXXXXXXX1234. • Masking format ID can be generated using the createMaskingFormat API. |
saveExceptions | boolean | When set to true, the Smart Check functionality is turned on, and arrays containing tokenization data are returned. |
Returned Values
Returned the following.
A decrypted value or an array of decrypted value(s).
TmResult which provides a string array of tokenization data. Specifically an array of indices pointing to incorrect “row-level” input items returned by TmResult, along with associated error messages that provide information which is useful in identifying the instances of erroneous row level data.
Exception
Passes an exception if:
The table or batch-level error occurs or an element is missing.
The input value is null or invalid.
The values and customData arrays are not the same size.
The CT-V cannot decrypt the value.
The token and customData arrays do not have the same number of elements.
A customData element is too long.
Note
For useful context about the Smart Check feature, see Smart Check.
Example
get("5541997351273456", "CREDIT_CARD_NUMBERS", TokenService.MASK_TOKEN).
The method does the following:
Looks up the encryption key for the Credit_Card_Numbers row in the key table.
Requests the key from the Key Manager.
Uses the token to find the ciphertext in the token vault.
Decrypts the ciphertext.
Returns the plaintext in the masked format (XXXXXXXXXXXX3456).
The last parameter controls the plaintext format. To mask the original value in X’s and reveal only the last four digits, use TokenService.MASK_TOKEN as shown above. To return the full plaintext, call get("5541997351273456", "CREDIT_CARD_NUMBERS", 0).