static void InternalTesting() { try { foreach (var item in trackPayload) { PinDecryptor decryptor = new PinDecryptor(); // decryptor in action byte[] trackInformation = decryptor.DecryptData(item.KSN, item.EncryptedData); string decryptedTrack = ConversionHelper.ByteArrayToHexString(trackInformation); //1234567890|1234567890|12345 Debug.WriteLine($"OUTPUT ____: {decryptedTrack}"); Console.WriteLine($"OUTPUT : [{decryptedTrack}]"); byte[] expectedValue = ConversionHelper.HexToByteArray(item.DecryptedData); bool result = StructuralComparisons.StructuralEqualityComparer.Equals(expectedValue, trackInformation); Console.WriteLine($"EQUAL : [{result}]"); OnlinePinData pinData = decryptor.RetrievePinData(trackInformation); Console.WriteLine($"CHOLDER: [{pinData.PANData}]"); } } catch (Exception e) { Console.WriteLine($"EXCEPTION: {e.Message}"); } }
static void DecryptOnlinePin(IConfiguration configuration, int index) { var onlinePin = configuration.GetSection("OnlinePinGroup:OnlinePin") .GetChildren() .ToList() .Select(x => new { onlinePinKsn = x.GetValue <string>("KSN"), onlinePinPan = x.GetValue <string>("PAN"), onlineEncryptedPin = x.GetValue <string>("EncryptedPin"), onlineDecryptedPin = x.GetValue <string>("DecryptedPin") }); // Is there a matching item? if (onlinePin.Count() > index) { string onlinePinKsn = onlinePin.ElementAt(index).onlinePinKsn; string onlinePinPan = onlinePin.ElementAt(index).onlinePinPan; string onlineEncryptedPin = onlinePin.ElementAt(index).onlineEncryptedPin; string onlineDecryptedPin = onlinePin.ElementAt(index).onlineDecryptedPin; try { //1234567890|1234567890|12345 Console.WriteLine($"==== [ ONLINE PIN DECRYPTION ] ===="); PinDecryptor decryptor = new PinDecryptor(); Debug.WriteLine($"KSN : {onlinePinKsn}"); Console.WriteLine($"KSN : {onlinePinKsn}"); Console.WriteLine($"DATA : {onlineEncryptedPin}"); // decryptor in action byte[] pinInformation = decryptor.DecryptData(onlinePinKsn, onlineEncryptedPin); string decryptedPin = ConversionHelper.ByteArrayToHexString(pinInformation); //1234567890|1234567890|12345 Console.WriteLine($"OUTPUT : {decryptedPin}"); Debug.WriteLine($"OUTPUT ____: {decryptedPin}"); OnlinePinData pinInfo = decryptor.RetrievePinData(pinInformation); //1234567890|1234567890|12345 Debug.WriteLine($"PAN DATA : {pinInfo.PANData}"); byte[] expectedValue = ConversionHelper.HexToByteArray(onlineDecryptedPin); bool result = StructuralComparisons.StructuralEqualityComparer.Equals(expectedValue, pinInformation); Console.WriteLine($"EQUAL ___: [{result}]"); } catch (Exception e) { Console.WriteLine($"EXCEPTION: {e.Message}"); } } }
static void ConfigurationLoad() { // Get appsettings.json config. IConfiguration configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .Build(); var onlinePin = configuration.GetSection("OnlinePinGroup:OnlinePin") .GetChildren() .ToList() .Select(x => new { onlinePinKsn = x.GetValue <string>("KSN"), onlinePinData = x.GetValue <string>("EncryptedData") }); // set the target index int index = 0; if (onlinePin.Count() > index) { string onlinePinKsn = onlinePin.ElementAt(index).onlinePinKsn; string onlinePinData = onlinePin.ElementAt(index).onlinePinData; try { PinDecryptor decryptor = new PinDecryptor(); Debug.WriteLine($"KSN : {onlinePinKsn}"); Console.WriteLine($"KSN : {onlinePinKsn}"); Console.WriteLine($"DATA : {onlinePinData}"); // decryptor in action byte[] trackInformation = decryptor.DecryptData(onlinePinKsn, onlinePinData); string decryptedTrack = ConversionHelper.ByteArrayToHexString(trackInformation); //1234567890|1234567890|12345 Console.WriteLine($"OUTPUT : {decryptedTrack}"); Debug.WriteLine($"OUTPUT ____: {decryptedTrack}"); //MSRTrackData trackInfo = decryptor.RetrieveAdditionalData(trackInformation); OnlinePinData pinInfo = decryptor.RetrievePinData(trackInformation); //1234567890|1234567890|12345 Debug.WriteLine($"PAN DATA : {pinInfo.PANData}"); } catch (Exception e) { Console.WriteLine($"EXCEPTION: {e.Message}"); } } }
public OnlinePinDecryptorTests() { subject = new PinDecryptor(); }