Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string bdk = "0123456789ABCDEFFEDCBA9876543210";
            string ksn = "629949012C0000000003";

            byte[] superSecretMessage = Encoding.UTF8.GetBytes("1234");
            byte[] encryptedData      = DUKPT.Encrypt(bdk, ksn, superSecretMessage, DUKPTVariant.PIN);
            String hexres             = BitConverter.ToString(encryptedData);

            hexres = hexres.Replace("-", "");
            Console.WriteLine("Encrypted Data: " + hexres);

            byte[] decryptedData       = DUKPT.Decrypt(bdk, ksn, encryptedData, DUKPTVariant.PIN);
            string superSecretMessage1 = Encoding.UTF8.GetString(decryptedData);

            Console.WriteLine("Decrypted Data: " + superSecretMessage1);
        }
Exemplo n.º 3
0
 public void Test_PEK_Encryption_Empty_KSN()
 {
     byte[] decryptedBytes = DUKPT.Encrypt(_bdk, string.Empty, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.PIN);
 }
Exemplo n.º 4
0
 public void Test_PEK_Encryption_Null_BDK()
 {
     byte[] decryptedBytes = DUKPT.Encrypt(null, _ksn, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.PIN);
 }
Exemplo n.º 5
0
 public void Test_PEK_Encryption_Null_Data()
 {
     byte[] decryptedBytes = DUKPT.Encrypt(_bdk, _ksn, null, DUKPTVariant.PIN);
 }
Exemplo n.º 6
0
 public void Test_PEK_Encryption_Invalid_Length_KSN()
 {
     byte[] encryptedBytes = DUKPT.Encrypt(_bdk, _ksn.Substring(0, 2), Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.PIN);
 }
Exemplo n.º 7
0
 public void Test_DEK_Encryption_Empty_BDK()
 {
     byte[] decryptedBytes = DUKPT.Encrypt(string.Empty, _ksn, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.Data);
 }
Exemplo n.º 8
0
 public void Test_DEK_Encryption_Null_KSN()
 {
     byte[] decryptedBytes = DUKPT.Encrypt(_bdk, null, Encoding.UTF8.GetBytes(_clearData), DUKPTVariant.Data);
 }
Exemplo n.º 9
0
 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);
 }