NET API
HSM Dinamo
Loading...
Looking for...
No entries found
tokenization.cs

Example of tokenization with the SVault module using token generation and secret recovery.

See Note on examples.
using System;
using System.IO;
using Dinamo.Hsm;
namespace Tokenization
{
class Program
{
static void Main(string[] args)
{
string address = "10.0.0.1";
string user = "master";
string pass = "12345678";
//Conecta ao HSM
hsm.Connect(address, user, pass);
/*
*
* Digit test.
*
*/
string mk = "aes256"; //Name of key in HSM
string cpf = "26122200468"; //CPF to be tokenized
SVaultGenTokenResponse svaultResponse = hsm.GenSVaultDigitToken(DinamoApi. D_SVAULT_CKS_CPF,
DinamoApi. D_SVAULT_F_MASK_SECRET,
mk,
cpf);
Console.WriteLine("Token (cpf): {0}", svaultResponse.Token);
/*
* Recover the secret.
*/
string mask = "";
string secret = hsm.GetSVaultSecret(mk, mask, svaultResponse.TokenBlob);
Console.WriteLine("Secret (cpf): {0}", secret);
/*
* Applies a mask that covers the first 3 and last 3 digits of the CPF with the "*" character.
* */
mask = "***\0\0\0***";
string maskedSecret = hsm.GetSVaultSecret(mk,
mask,
svaultResponse.TokenBlob);
Console.WriteLine("Masked secret (cpf): {0}", maskedSecret);
/*
*
* String test.
*
*/
string text = "This is a test";
mk,
text);
Console.WriteLine("Token (string): {0}", svaultResponse.Token);
/*
* Recover the secret.
*/
mask = "";
secret = hsm.GetSVaultSecret(mk, mask, svaultResponse.TokenBlob);
Console.WriteLine("Secret (string): {0}", secret);
/*
* Applies a mask to the string.
* */
mask = "***is***\0\0";
maskedSecret = hsm.GetSVaultSecret(mk,
mask,
svaultResponse.TokenBlob);
Console.WriteLine("Masked secret (string): {0}", maskedSecret);
hsm.Disconnect();
}
}
}
Low-level class for accessing the HSM. To use this class you need to understand more ...
Definition DinamoApi.cs:15
const byte D_SVAULT_F_MASK_SECRET
Definition DinamoApi.cs:1417
const byte D_SVAULT_CKS_CPF
Definition DinamoApi.cs:1420
API class for accessing HSM functionalities Dinamo. In this class you can program using...
Definition DinamoClient.cs:93
Class that encapsulates the generation of a blob and token from a tokenization operation.
Definition DinamoClient.cs:52
byte[] TokenBlob
Definition DinamoClient.cs:53
Token string
Definition DinamoClient.cs:54
void Connect(string User, string Password)
Establishes an encrypted connection to the HSM using the load balance settings.
Definition DinamoClient.cs:562
void Disconnect(bool flagClose)
Terminates the connection to the HSM.
Definition DinamoClient.cs:814
string GetSVaultSecret(string MK, string Mask, byte[] TokenBlob)
Retrieves the secret of tokenized data using a token blob. This API also allows you to retrieve ...
Definition DinamoClient.cs:3118
SVaultGenTokenResponse GenSVaultDigitToken(byte CKS, byte MaskFlags, string MK, string Secret)
It tokenizes digits, generating a token blob and its respective token.
Definition DinamoClient.cs:2997
SVaultGenTokenResponse GenSVaultStringToken(byte MaskFlags, string MK, string Secret)
It tokenizes a UTF-8 string, generating a token blob and its respective token.
Definition DinamoClient.cs:3030
Namespace denoting a set of functions for accessing the HSM Dinamo and their respective exceptions.
Definition DinamoClient.cs:12