コード例 #1
0
ファイル: Form1.cs プロジェクト: DMSys/BaseSource
        private void btn_Decrypt3DES_Click(object sender, EventArgs e)
        {
            string encryptText = tb_EncryptText.Text;
            string csPassword  = tb_Password.Text;

            CryptoSymmetric crypto = new CryptoSymmetric();

            crypto.CryptoType   = CryptoSymmetric.CryptoTypes.TripleDES;
            crypto.StringFormat = StringFormats.HEX;

            string decryptText = crypto.Decrypt(encryptText, csPassword);

            tb_DecryptText.Text = decryptText;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: DMSys/BaseSource
        private void btn_Decrypt3DES192_Click(object sender, EventArgs e)
        {
            string encryptText = tb_EncryptText.Text;
            string csPassword  = tb_Password.Text;
            string csIV        = tb_InitializationVector.Text;

            CryptoSymmetric crypto = new CryptoSymmetric();

            crypto.CryptoType   = CryptoSymmetric.CryptoTypes.TripleDES_192;
            crypto.StringFormat = StringFormats.HEX;
            crypto.CalculateKey = false;

            string decryptText = crypto.Decrypt(encryptText, csPassword, csIV);

            tb_DecryptText.Text = decryptText;
        }
コード例 #3
0
        /// <summary>
        /// Проверява Рег.Номер
        /// </summary>
        /// <param name="registrationNumber">Рег.Номер</param>
        /// <returns></returns>
        public bool Validation(string registrationNumber, DateTime?limiteDate = null)
        {
            if (registrationNumber == "")
            {
                return(false);
            }
            try
            {
                _IsValid = Validation(registrationNumber
                                      , _ProcessorId
                                      , _ApplicationID
                                      , _ApplicationKey
                                      , _ApplicationIv);
                // Добава лимитиране, ако 'Рег.Номер' е валиден
                if (_IsValid && (limiteDate != null))
                {
                    if (_RegistrationDate > limiteDate)
                    {
                        _RegistrationDate = (DateTime)limiteDate;

                        CryptoSymmetric crypto = new CryptoSymmetric();
                        crypto.CryptoType   = CryptoSymmetric.CryptoTypes.TripleDES_192;
                        crypto.StringFormat = StringFormats.HEX;
                        crypto.CalculateKey = false;

                        string processorId = crypto.Decrypt(_ApplicationID, _ApplicationKey, _ApplicationIv);
                        string uniAppId    = Hashing.Hash(processorId, Hashing.HashingTypes.MD5, Hashing.EncodingTypes.ASCII, StringFormats.BIT).Substring(0, 15);
                        string validUntil  = _RegistrationDate.ToString("yyyyMMdd");
                        _RegistrationNumber = crypto.Encrypt(validUntil + uniAppId, _ApplicationKey, _ApplicationIv);
                    }
                }
            }
            catch
            { _IsValid = false; }
            return(_IsValid);
        }