Esempio n. 1
0
        public TranslateResult TranslatePin(string pinBlock, string track2)
        {
            Sessions_Core_ZPK_to_TPK tpkzpk;
            string             pin;
            string             errorCode;
            TritonCryptography crypt = new TritonCryptography();

            _log.Debug("Geting Keys for Pin Translation");
            using (var terData = new TerminalData())
            {
                tpkzpk = terData.GetTPKZPKByTerminalId(_terminalId);
            }
            _log.Debug("Formatting PAN");
            string accNumber = track2.Substring(0, track2.IndexOf("=", StringComparison.Ordinal));

            accNumber = accNumber.Substring(accNumber.Length - 13, 12);

            _log.Debug("Translating Pin Block");
            var translateResult = crypt.TranslatePIN_TDES(tpkzpk.TPK_LMK, tpkzpk.ZPK_LMK, pinBlock, accNumber);

            translateResult.TryGetValue("DestPIN", out pin);
            translateResult.TryGetValue("ErrorCode", out errorCode);

            var result = new List <TranslateResult> {
                new TranslateResult {
                    PinBlock = pin, ErrorCode = errorCode
                }
            };

            return(result.FirstOrDefault());
        }
        public void Test_TranslatePIN_TDES()
        {
            TritonCryptography terminalCrypto = new TritonCryptography();

            //D4
            //U61C0EA6E706F5B2DAF57B37C7D825D04
            //U88EE45E510C981FC928F95EAB01EAA28
            //0D12F42095EF12A2
            //237000000234
            string accNumber = "4902370000002348=121210111234123";
            string bin       = accNumber.Substring(0, 6);

            accNumber = accNumber.Substring(0, accNumber.IndexOf("=", StringComparison.Ordinal));
            accNumber = accNumber.Substring(accNumber.Length - 13, 12);

            Dictionary <String, String> response = terminalCrypto.TranslatePIN_TDES("U61C0EA6E706F5B2DAF57B37C7D825D04", "U88EE45E510C981FC928F95EAB01EAA28", "0D12F42095EF12A2", accNumber);

            if (response.ContainsKey("ErrorCode"))
            {
                Assert.AreEqual((response["ErrorCode"]), "00");
            }
        }