// Path: cryptocard/src/main/java/com/indarsoft/cryptocard/symmetrickey/Pvk.java
// public class Pvk extends DesKey {
// 
// 	private int pvki ;
// 	/**
// 	 * PVK constructor
// 	 * @param aKey	DES key double length.
// 	 * @param pvki	pvki
// 	 * @throws DesKeyException if a exception arrives
// 	 */
// 	public Pvk (String aKey ,  int pvki  ) throws DesKeyException  {
// 		
// 		 super(aKey );
// 		 if ( ! validatePvki ( pvki ) ) throw new DesKeyException("Wrong Key - pvki must be Decimal between 1 and six !!") ;
// 		 /*
// 		  * Do not enforce this, because PVK is also used for IBM3264offset method
// 		  */
// 		 //if ( aKey.length() != 32 )  	throw new DesKeyException("Wrong Key - DOUBLE deskey Must be 32 long Hexadecimal data!!");
// 		 this.pvki = pvki ;
// 	}
// 	/**
// 	 * PVK constructor with default pvki = 1.
// 	 * @param aKey	DES key double length
// 	 * @throws DesKeyException if a exception arrives
// 	 */
// 	public Pvk (String aKey  ) throws DesKeyException  {
// 		
// 		 this (aKey, 1 );
// 	}
// 	
// 	public int getPvki () {
// 		return this.pvki ;				
// 	}
// 	
// 	private static Boolean validatePvki ( int pvki ){
// 		
// 		if ( pvki < 1 || pvki > 6 ){
// 			return false ;	
// 		}
// 		return true ;
// 	}		
// 	
// }
// 
// Path: cryptocard/src/main/java/com/indarsoft/cryptocard/types/DesKeyType.java
// public enum DesKeyType {
// 
// 	SIMPLE(0), DOUBLE(1), TRIPLE(2) ;
//     @SuppressWarnings("unused")
// 	private int value;
// 
//     private DesKeyType (int value) {
//             this.value = value;
//     }	
// }


import com.indarsoft.cryptocard.symmetrickey.Pvk;
import com.indarsoft.cryptocard.types.DesKeyType;
import com.indarsoft.utl.Ascii;
import com.indarsoft.utl.Binary;
import com.indarsoft.utl.Des;

	 * Natural Pin calculation.
	 * <pre>
	 * - Validate Pin Validation Data
	 * - DES or Tdes of Pin Validation data (depending of Pvk length)
	 * - Take N-bytes (N=pin length/2) and decimalize this data
	 * - Natural Pin --{@literal>} Return previous result as string  
	 * </pre> 	
	 * @param pinValidationData input pin validation data 
	 * @param pinLength	pin length 
	 * @return natural pin generated
	 * @throws Exception if a exception arrives
	 */	
	public String calculateNaturalPin (  String pinValidationData ,  int pinLength  ) throws Exception {

		byte[] blkA	= new byte[BLK16];
		byte[] blkB	;
		//	
		for (int i=0; i < pinValidationData.length() ; i++){
			 blkA[i] = (byte) Character.getNumericValue( pinValidationData.charAt(i) ) ;
		} 
		
		isvalidPinValidationData(pinValidationData);
		/*
		 * 	Compress the builded block to 64 bits
		 */		
		blkB = Binary.compressBlock( blkA  ) ; 		
		
		/* Encrypt the blkB  */
		byte [] blkEncrypted = new byte[ BLK08 ];
	

// Path: cryptocard/src/main/java/com/indarsoft/cryptocard/symmetrickey/Pvk.java
// public class Pvk extends DesKey {
// 
// 	private int pvki ;
// 	/**
// 	 * PVK constructor
// 	 * @param aKey	DES key double length.
// 	 * @param pvki	pvki
// 	 * @throws DesKeyException if a exception arrives
// 	 */
// 	public Pvk (String aKey ,  int pvki  ) throws DesKeyException  {
// 		
// 		 super(aKey );
// 		 if ( ! validatePvki ( pvki ) ) throw new DesKeyException("Wrong Key - pvki must be Decimal between 1 and six !!") ;
// 		 /*
// 		  * Do not enforce this, because PVK is also used for IBM3264offset method
// 		  */
// 		 //if ( aKey.length() != 32 )  	throw new DesKeyException("Wrong Key - DOUBLE deskey Must be 32 long Hexadecimal data!!");
// 		 this.pvki = pvki ;
// 	}
// 	/**
// 	 * PVK constructor with default pvki = 1.
// 	 * @param aKey	DES key double length
// 	 * @throws DesKeyException if a exception arrives
// 	 */
// 	public Pvk (String aKey  ) throws DesKeyException  {
// 		
// 		 this (aKey, 1 );
// 	}
// 	
// 	public int getPvki () {
// 		return this.pvki ;				
// 	}
// 	
// 	private static Boolean validatePvki ( int pvki ){
// 		
// 		if ( pvki < 1 || pvki > 6 ){
// 			return false ;	
// 		}
// 		return true ;
// 	}		
// 	
// }
// 
// Path: cryptocard/src/main/java/com/indarsoft/cryptocard/types/DesKeyType.java
// public enum DesKeyType {
// 
// 	SIMPLE(0), DOUBLE(1), TRIPLE(2) ;
//     @SuppressWarnings("unused")
// 	private int value;
// 
//     private DesKeyType (int value) {
//             this.value = value;
//     }	
// }


// Path: cryptocard/src/main/java/com/indarsoft/cryptocard/customerverify/Ibm3624Offset.java
import com.indarsoft.cryptocard.symmetrickey.Pvk;
import com.indarsoft.cryptocard.types.DesKeyType;
import com.indarsoft.utl.Ascii;
import com.indarsoft.utl.Binary;
import com.indarsoft.utl.Des;

	 * Natural Pin calculation.
	 * <pre>
	 * - Validate Pin Validation Data
	 * - DES or Tdes of Pin Validation data (depending of Pvk length)
	 * - Take N-bytes (N=pin length/2) and decimalize this data
	 * - Natural Pin --{@literal>} Return previous result as string  
	 * </pre> 	
	 * @param pinValidationData input pin validation data 
	 * @param pinLength	pin length 
	 * @return natural pin generated
	 * @throws Exception if a exception arrives
	 */	
	public String calculateNaturalPin (  String pinValidationData ,  int pinLength  ) throws Exception {

		byte[] blkA	= new byte[BLK16];
		byte[] blkB	;
		//	
		for (int i=0; i < pinValidationData.length() ; i++){
			 blkA[i] = (byte) Character.getNumericValue( pinValidationData.charAt(i) ) ;
		} 
		
		isvalidPinValidationData(pinValidationData);
		/*
		 * 	Compress the builded block to 64 bits
		 */		
		blkB = Binary.compressBlock( blkA  ) ; 		
		
		/* Encrypt the blkB  */
		byte [] blkEncrypted = new byte[ BLK08 ];
	

		if ( pvk.getKeyType() == DesKeyType.SIMPLE ){
