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

Example of CVV generation and verification.

See Note on examples.
using System;
using System.IO;
using Dinamo.Hsm;
namespace EFTGenVerifyCVV
{
class Program
{
static void Main(string[] args)
{
string address = "127.0.0.1";
string user = "master";
string pass = "12345678";
/*
Connects to HSM
*/
hsm.Connect(address, user, pass);
/*
Import test key
*/
string keyId = "cvk";
byte[] keyData = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
IntPtr keyHandle = hsm.ImportKey(keyId, IntPtr.Zero, keyData,
DinamoClient.BLOB_TYPE.PLAINTEXTKEY_BLOB,
DinamoClient.KEY_ALG.ALG_3DES_112);
/*
Generate a CVV
This test generates CVV 561.
*/
string pan ="4123456789012345";
string expirationDate ="8701";
string serviceCode ="101";
string cvv = hsm.GenCVV(keyId, pan, expirationDate, serviceCode);
Console.WriteLine("cvv: {0}", cvv);
bool isValidCvv = hsm.VerifyCVV(keyId, pan, expirationDate,
serviceCode, cvv);
Console.WriteLine("cvv is {0}!", isValidCvv ? "valid" : "invalid");
/*
Release handle, remove key and disconnect
*/
hsm.DestroyKey(keyHandle);
hsm.RemoveObject(keyId);
hsm.Disconnect();
}
}
}
API class for accessing HSM functionalities Dinamo. In this class you can program using...
Definition DinamoClient.cs:93
KEY_ALG
Definition DinamoClient.cs:227
BLOB_TYPE
Definition DinamoClient.cs:449
string GenCVV(string keyId, string pan, string expirationDate, string serviceCode)
Generates a CVV (Card Verification Value), CVV2 or iCVV using a key within HSM....
Definition DinamoClient.cs:4339
bool VerifyCVV(string keyId, string pan, string expirationDate, string serviceCode, string cvv)
Verifies a CVV (Card Verification Value), CVV2 or iCVV using a key within HSM....
Definition DinamoClient.cs:4364
void DestroyKey(IntPtr hKey)
Release key handle.
Definition DinamoClient.cs:1953
IntPtr ImportKey(string KeyId, IntPtr hKeyEncryptionKey, byte[] byKeyBlob, BLOB_TYPE BlobType, KEY_ALG AlgId)
Definition DinamoClient.cs:2668
void RemoveObject(string ObjectId)
Removes an object from the HSM.
Definition DinamoClient.cs:2397
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
Namespace denoting a set of functions for accessing the HSM Dinamo and their respective exceptions.
Definition DinamoClient.cs:12