Exemplo n.º 1
0
        private void tbClearAwk_TextChanged(object sender, EventArgs e)
        {
            string content = tbClearAwk.Text;

            if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
            {
                _hLabelClearAwk.Clear();
                _validClearAwk = false;
                return;
            }

            content = content.Replace(" ", "");

            foreach (char c in content)
            {
                if (!Helper.IsHexChar(c))
                {
                    _hLabelClearAwk.SetHint(Color.Red, "AWK must only contain hex digits");
                    _validClearAwk = false;
                    return;
                }
            }

            if (content.Length != 32)
            {
                _hLabelClearAwk.SetHint(Color.Red, "AWK size must be 16 bytes");
                _validClearAwk = false;
                return;
            }

            _hLabelClearAwk.SetHint(Color.Black, "Check value: " + Encryptor.Instance.CalKCV(content));
            _validClearAwk = true;
        }
Exemplo n.º 2
0
        private void tbPan_TextChanged(object sender, EventArgs e)
        {
            string content = tbPan.Text;

            if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
            {
                _hLabelPan.Clear();
                _validPan = false;
                return;
            }

            foreach (char c in content)
            {
                if (!Helper.IsDigit(c))
                {
                    _hLabelPan.SetHint(Color.Red, "PAN must only contain digits");
                    _validPan = false;
                    return;
                }
            }

            if (content.Length < 13 || content.Length > 19)
            {
                _hLabelPan.SetHint(Color.Red, "Invalid PAN length");
                _validPan = false;
                return;
            }

            _hLabelPan.Clear();
            _validPan = true;
        }
Exemplo n.º 3
0
        private void tbServiceCode_TextChanged(object sender, EventArgs e)
        {
            string content = tbServiceCode.Text;

            if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
            {
                _hLabelServiceCode.Clear();
                _validServiceCode = false;
                return;
            }

            foreach (char c in content)
            {
                if (!Helper.IsDigit(c))
                {
                    _hLabelServiceCode.SetHint(Color.Red, "Service code must only contain digits");
                    _validServiceCode = false;
                    return;
                }
            }

            if (content.Length != 3)
            {
                _hLabelServiceCode.SetHint(Color.Red, "Invalid service code length");
                _validServiceCode = false;
                return;
            }

            _hLabelServiceCode.Clear();
            _validServiceCode = true;
        }
Exemplo n.º 4
0
        private void tbBlockB_TextChanged(object sender, EventArgs e)
        {
            string content = tbBlockB.Text;

            if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
            {
                _hLabelBlockB.Clear();
                _validBlockB = false;
                tbXor.Text   = string.Empty;
                return;
            }

            foreach (char c in content)
            {
                if (!Helper.IsHexChar(c))
                {
                    _hLabelBlockB.SetHint(Color.Red, "Block can only contain hex digit");
                    _validBlockB = false;
                    return;
                }
            }

            _validBlockB = true;
            _hLabelBlockB.Clear();

            if (_validBlockA && _validBlockB)
            {
                tbXor.Text = Encryptor.Instance.Xor(tbBlockA.Text, content);
            }
        }
Exemplo n.º 5
0
        private void tbPinBlockEncrypted_TextChanged(object sender, EventArgs e)
        {
            if (!tbPinBlockEncrypted.ReadOnly)
            {
                string content = tbPinBlockEncrypted.Text;

                if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
                {
                    _hLabelPinBlockEncrypted.Clear();
                    _validPinBlockEncrypted = false;

                    tbPin.ReadOnly = false;
                    btnCalculatePinBlock.Enabled = true;

                    tbPinBlock.Text = string.Empty;
                    tbPin.Text      = string.Empty;

                    return;
                }

                tbPin.ReadOnly = true;
                btnCalculatePinBlock.Enabled = false;

                foreach (char c in content)
                {
                    if (!Helper.IsHexChar(c))
                    {
                        _hLabelPinBlockEncrypted.SetHint(Color.Red, "Block must only contain hex digits");
                        _validPinBlockEncrypted = false;
                        return;
                    }
                }

                if (content.Length != 16)
                {
                    _hLabelPinBlockEncrypted.SetHint(Color.Red, "Block size must be 8 bytes");
                    _validPinBlockEncrypted = false;
                    return;
                }

                _hLabelPinBlockEncrypted.Clear();
                _validPinBlockEncrypted = true;
            }
        }
Exemplo n.º 6
0
        private void tbPin_TextChanged(object sender, EventArgs e)
        {
            if (!tbPin.ReadOnly)
            {
                string content = tbPin.Text;

                if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
                {
                    _hLabelPin.Clear();
                    _validPin = false;

                    tbPinBlockEncrypted.ReadOnly = false;
                    btnCalculatePin.Enabled      = true;

                    tbPinBlockEncrypted.Text = string.Empty;
                    tbPinBlock.Text          = string.Empty;

                    return;
                }

                tbPinBlockEncrypted.ReadOnly = true;
                btnCalculatePin.Enabled      = false;

                foreach (char c in content)
                {
                    if (!Helper.IsDigit(c))
                    {
                        _hLabelPin.SetHint(Color.Red, "PIN must only contain digits");
                        _validPin = false;
                        return;
                    }
                }

                if (content.Length < 4 || content.Length > 6)
                {
                    _hLabelPin.SetHint(Color.Red, "Invalid PIN length");
                    _validPin = false;
                    return;
                }

                _hLabelPin.Clear();
                _validPin = true;
            }
        }
Exemplo n.º 7
0
        //-------------------------------------------------------------------------------------------------------
        #region Event handlers
        //-------------------------------------------------------------------------------------------------------

        private void tbDataBlock_TextChanged(object sender, EventArgs e)
        {
            string content = tbDataBlock.Text;

            if (string.IsNullOrEmpty(content) || string.IsNullOrWhiteSpace(content))
            {
                _hLabelDataBlock.Clear();
                _validDataBlock = false;
                return;
            }

            content = content.Replace(" ", "");

            foreach (char c in content)
            {
                if (!Helper.IsHexChar(c))
                {
                    _hLabelDataBlock.SetHint(Color.Red, "Block must only contain hex digits");
                    _validDataBlock = false;
                    return;
                }
            }

            if (content.Length < 16)
            {
                _hLabelDataBlock.SetHint(Color.Red, "Block size must be at leaset 8 bytes");
                _validDataBlock = false;
                return;
            }

            if (!IsPowOfTwo(content.Length))
            {
                _hLabelDataBlock.SetHint(Color.Red, "Block size must be power of two");
                _validDataBlock = false;
                return;
            }

            _validDataBlock = true;
            _hLabelDataBlock.Clear();
        }