public void Test_PEK_Decryption() { byte[] decryptedBytes = Dukpt.Decrypt(_bdk, _ksn, _expectedEncryptedHexPEK.HexStringToByteArray(), DUKPTVariant.PIN); string decryptedData = Encoding.UTF8.GetString(decryptedBytes); Assert.AreEqual(decryptedData, _clearData); }
public void TestDecryption() { var clear = "%B5452300551227189^HOGAN/PAUL ^08043210000000725000000?\0\0\0\0"; var bdk = "0123456789ABCDEFFEDCBA9876543210"; var ksn = "FFFF9876543210E00008"; var track = "C25C1D1197D31CAA87285D59A892047426D9182EC11353C051ADD6D0F072A6CB3436560B3071FC1FD11D9F7E74886742D9BEE0CFD1EA1064C213BB55278B2F12"; var decBytes = Dukpt.Decrypt(bdk, ksn, track.HexStringToByteArray()); var decrypted = Encoding.UTF8.GetString(decBytes); Assert.AreEqual(decrypted, clear); }
static void Main(string[] args) { var test = "%B5452300551227189^HOGAN/PAUL ^08043210000000725000000?\0\0\0\0"; // Decrypting var bdk = "0123456789ABCDEFFEDCBA9876543210"; var ksn = "FFFF9876543210E00008"; var track = "C25C1D1197D31CAA87285D59A892047426D9182EC11353C051ADD6D0F072A6CB3436560B3071FC1FD11D9F7E74886742D9BEE0CFD1EA1064C213BB55278B2F12"; var decBytes = Dukpt.Decrypt(bdk, ksn, BigInt.FromHex(track).GetBytes()); var decrypted = UTF8Encoding.UTF8.GetString(decBytes); Console.WriteLine(decrypted == test); // Encrypting var encBytes = Dukpt.Encrypt(bdk, ksn, decBytes); var encrypted = BitConverter.ToString(encBytes).Replace("-", ""); Console.WriteLine(encrypted == track); }
public void Test_PEK_Decryption_Invalid_Length_KSN() { byte[] encryptedBytes = Dukpt.Decrypt(_bdk, _ksn.Substring(0, 2), _expectedEncryptedHexPEK.HexStringToByteArray(), DUKPTVariant.PIN); }
public void Test_DEK_Decryption_Empty_KSN() { byte[] decryptedBytes = Dukpt.Decrypt(_bdk, string.Empty, _expectedEncryptedHexDEK.HexStringToByteArray(), DUKPTVariant.Data); }
public void Test_DEK_Decryption_Null_BDK() { byte[] decryptedBytes = Dukpt.Decrypt(null, _ksn, _expectedEncryptedHexDEK.HexStringToByteArray(), DUKPTVariant.Data); }
public void Test_DEK_Decryption_Null_Data() { byte[] decryptedBytes = Dukpt.Decrypt(_bdk, _ksn, null, DUKPTVariant.Data); }
public void Test_DEK_Decryption_Invalid_Length_BDK() { byte[] encryptedBytes = Dukpt.Decrypt(_bdk.Substring(0, _bdk.Length / 2), _ksn, _expectedEncryptedHexDEK.HexStringToByteArray(), DUKPTVariant.Data); }
public void Test_PEK_Decryption_Empty_BDK() { byte[] decryptedBytes = Dukpt.Decrypt(string.Empty, _ksn, _expectedEncryptedHexDEK.HexStringToByteArray(), DUKPTVariant.PIN); }
public void Test_PEK_Decryption_Null_KSN() { byte[] decryptedBytes = Dukpt.Decrypt(_bdk, null, _expectedEncryptedHexDEK.HexStringToByteArray(), DUKPTVariant.PIN); }