public void Test_PEK_Encryption() { byte[] encryptedBytes = Dukpt.Encrypt(_bdk, _ksn, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.PIN); string encryptedHexResult = BitConverter.ToString(encryptedBytes).Replace("-", ""); Assert.AreEqual(encryptedHexResult, _expectedEncryptedHexPEK); }
public void TestEncryption() { var clear = "%B5452300551227189^HOGAN/PAUL ^08043210000000725000000?\0\0\0\0"; var bdk = "0123456789ABCDEFFEDCBA9876543210"; var ksn = "FFFF9876543210E00008"; var track = "C25C1D1197D31CAA87285D59A892047426D9182EC11353C051ADD6D0F072A6CB3436560B3071FC1FD11D9F7E74886742D9BEE0CFD1EA1064C213BB55278B2F12"; var encBytes = Dukpt.Encrypt(bdk, ksn, Encoding.UTF8.GetBytes(clear)); var encrypted = BitConverter.ToString(encBytes).Replace("-", ""); Assert.AreEqual(encrypted, track); }
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_Encryption_Empty_KSN() { byte[] decryptedBytes = Dukpt.Encrypt(_bdk, string.Empty, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.PIN); }
public void Test_PEK_Encryption_Null_BDK() { byte[] decryptedBytes = Dukpt.Encrypt(null, _ksn, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.PIN); }
public void Test_PEK_Encryption_Null_Data() { byte[] decryptedBytes = Dukpt.Encrypt(_bdk, _ksn, null, DUKPTVariant.PIN); }
public void Test_PEK_Encryption_Invalid_Length_KSN() { byte[] encryptedBytes = Dukpt.Encrypt(_bdk, _ksn.Substring(0, 2), Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.PIN); }
public void Test_DEK_Encryption_Empty_BDK() { byte[] decryptedBytes = Dukpt.Encrypt(string.Empty, _ksn, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.Data); }
public void Test_DEK_Encryption_Null_KSN() { byte[] decryptedBytes = Dukpt.Encrypt(_bdk, null, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.Data); }
public void Test_DEK_Encryption_Invalid_Length_BDK() { byte[] encryptedBytes = Dukpt.Encrypt(_bdk.Substring(0, _bdk.Length / 2), _ksn, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.Data); }