コード例 #1
0
        private void CmdGenerateFields_Click(object sender, EventArgs e)
        {
            //StringReader strReader = new StringReader(TxtTrackData.Text);
            string[] lines = TxtTrackInformation.Text.Replace("\r","").Split('\n');

            if (lines.Length < 21)
                MessageBox.Show("No Magensa Swipes to use");

            string encryptedTrack2 = lines[6].Substring(lines[6].IndexOf("=") + 1).Replace(" ", "");
            string encryptedMagnePrintData = lines[12].Substring(lines[12].IndexOf("=") + 1).Replace(" ", "");
            string DUKPTserialNo = lines[2].Substring(lines[2].IndexOf("=") + 1).Replace(" ", "");
            string magenPrintStatus = lines[10].Substring(lines[10].IndexOf("=") + 1).Replace(" ", "");

            //Get Masked Pan and CardType
            TxtTrack2Masked.Text = lines[18].Substring(lines[18].IndexOf("=") + 1).Replace(" ", "").Trim();
            HelperMethods h = new HelperMethods();
            string pan = TxtTrack2Masked.Text.Substring(1, TxtTrack2Masked.Text.IndexOf("=") - 1);

            int masklenght = pan.Length - 4;
            int count = 0;
            string maskingCount = "";
            do
            {
                maskingCount += "X";
                count++;
            } while (count < masklenght);

            TxtMaskedPAN.Text = maskingCount + pan.Substring(pan.Length - 4, 4);

            try { CboMagensaCardType.SelectedItem = h.CardTypeLookup(pan); }
            catch { }

            TxtMagnePrintData.Text = encryptedMagnePrintData;
            TxtDukptKeySerialNumber.Text = DUKPTserialNo;
            TxtTrack2EncryptedData.Text = encryptedTrack2;
            TxtMagnePrintStatus.Text = magenPrintStatus;
        }
コード例 #2
0
        private void CmdGenerateFields_Click(object sender, EventArgs e)
        {
            // The below code is specific to the newer version of the MagTek Dynamag USB MSR
            // It takes the raw swipe generated from the Dynamag to populate the correct lines below.
            try
            {
                if (ChkPipeDelimited.Checked)
                {
                    string[] lines = TxtTrackInformation.Text.Split('|');

                    if (lines.Length < 13)
                        MessageBox.Show("No Magensa Swipes to use");
                    else
                    {
                        string encryptedTrack2 = lines[3];
                        string encryptedMagnePrintData = lines[6];
                        string DUKPTserialNo = lines[9];
                        string magenPrintStatus = lines[5];
                        string deviceSerialNum = lines[7];
                        string txtTrack2Masked = lines[0].Substring(lines[0].IndexOf(";") + 1).Replace("?", "").Trim();
                        //string pan = txtTrack2Masked.Substring(0, 16);
                        string[] track2 = txtTrack2Masked.Split('=');
                        string panTrack2 = track2[0];
                        string discTrack2 = track2[1];

                        //Get Masked Pan and CardType

                        HelperMethods h = new HelperMethods();

                        int masklength = panTrack2.Length - 10;
                        int count = 0;
                        string maskingCount = panTrack2.Substring(0, 6);
                        do
                        {
                            maskingCount += "X";
                            count++;
                        } while (count < masklength);

                        TxtMaskedPAN.Text = maskingCount + panTrack2.Substring(panTrack2.Length - 4, 4);

                        masklength = discTrack2.Length - 4;
                        maskingCount = discTrack2.Substring(0, 4);
                        count = 0;
                        do
                        {
                            maskingCount += "X";
                            count++;
                        } while (count < masklength);

                        TxtTrack2Masked.Text = TxtMaskedPAN.Text + "=" + maskingCount;

                        try { CboMagensaCardType.SelectedItem = h.CardTypeLookup(panTrack2); }
                        catch { }

                        TxtMagnePrintData.Text = encryptedMagnePrintData;
                        TxtDukptKeySerialNumber.Text = DUKPTserialNo;
                        TxtTrack2EncryptedData.Text = encryptedTrack2;
                        TxtMagnePrintStatus.Text = magenPrintStatus;
                        TxtDeviceSerialNumber.Text = deviceSerialNum;
                    }
                }
                else
                {
                    //StringReader strReader = new StringReader(TxtTrackData.Text);
                    string[] lines = TxtTrackInformation.Text.Replace("\r", "").Split('\n');

                    if (lines.Length < 21)
                        MessageBox.Show("No Magensa Swipes to use");
                    else
                    {

                        string encryptedTrack2 = lines[6].Substring(lines[6].IndexOf("=") + 1).Replace(" ", "");
                        string encryptedMagnePrintData = lines[12].Substring(lines[12].IndexOf("=") + 1).Replace(" ", "");
                        string DUKPTserialNo = lines[2].Substring(lines[2].IndexOf("=") + 1).Replace(" ", "");
                        string magenPrintStatus = lines[10].Substring(lines[10].IndexOf("=") + 1).Replace(" ", "");
                        string deviceSerialNum = lines[14].Substring(lines[14].IndexOf("=") + 2);

                        string txtTrack2Masked = lines[18].Substring(lines[18].IndexOf(";") + 1).Replace("?", "").Trim();
                        string[] track2 = txtTrack2Masked.Split('=');
                        string panTrack2 = track2[0];
                        string discTrack2 = track2[1];

                        //Get Masked Pan and CardType
                        TxtTrack2Masked.Text = lines[18].Substring(lines[18].IndexOf("=") + 1).Replace(" ", "").Trim();
                        HelperMethods h = new HelperMethods();

                        int masklength = panTrack2.Length - 8;
                        int count = 0;
                        string maskingCount = panTrack2.Substring(0, 4);
                        do
                        {
                            maskingCount += "X";
                            count++;
                        } while (count < masklength);

                        TxtMaskedPAN.Text = maskingCount + panTrack2.Substring(panTrack2.Length - 4, 4);

                        masklength = discTrack2.Length - 4;
                        maskingCount = discTrack2.Substring(0, 4);
                        count = 0;
                        do
                        {
                            maskingCount += "X";
                            count++;
                        } while (count < masklength);

                        TxtTrack2Masked.Text = TxtMaskedPAN.Text + "=" + maskingCount;

                        try { CboMagensaCardType.SelectedItem = h.CardTypeLookup(panTrack2); }
                        catch { }

                        TxtMagnePrintData.Text = encryptedMagnePrintData;
                        TxtDukptKeySerialNumber.Text = DUKPTserialNo;
                        TxtTrack2EncryptedData.Text = encryptedTrack2;
                        TxtMagnePrintStatus.Text = magenPrintStatus;
                        TxtDeviceSerialNumber.Text = deviceSerialNum;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }