Java API
HSM Dinamo
Loading...
Looking for...
No entries found
PINBlockTranslate.java

Example of PIN block translation.

See Note on examples.
package doxy.examples;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class PINBlockTranslate {
static String hsmIP = "127.0.0.1";
static String hsmUser = "master";
static String hsmUserPassword = "12345678";
static String keyName1 = "key1";
static String keyName2 = "key2";
static byte key1Data[] =
{
(byte)0x05, (byte)0x05, (byte)0x05, (byte)0x05,
(byte)0x05, (byte)0x05, (byte)0x05, (byte)0x05,
} ;
static byte key2Data[] =
{
(byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x23,
(byte)0x45, (byte)0x03, (byte)0x17, (byte)0x46,
} ;
public static void main(String[] args) throws TacException {
Dinamo api = new Dinamo();
System.out.println("Login HSM and create test keys");
api.openSession(hsmIP, hsmUser, hsmUserPassword);
api.importKey(keyName1, TacNDJavaLib.PLAINTEXTKEY_BLOB, TacNDJavaLib.ALG_DES, key1Data, true);
api.importKey(keyName2, TacNDJavaLib.PLAINTEXTKEY_BLOB, TacNDJavaLib.ALG_DES, key2Data, true);
String PAN = "4000001234569002";
byte inPINBlock[] =
{
(byte)0xAF, (byte)0xB0, (byte)0xB4, (byte)0x95,
(byte)0x55, (byte)0x3F, (byte)0x21, (byte)0xDC,
} ;
System.out.println("Translate PIN Block");
byte[] outPINBlock = api.translatePINBlock(keyName1,
keyName2,
TacNDJavaLib.TP_TRANSLATE_TYPE_ISO_0,
PAN,
inPINBlock);
System.out.print("Translated PIN Block: ");
for(byte pinBlockByte : outPINBlock)
{
System.out.print(String.format("%02x ", pinBlockByte));
}
System.out.println("\nRemove test keys");
api.deleteKey(keyName1);
api.deleteKey(keyName2);
api.closeSession();
System.out.println("The process ended sucessfully");
}
}