Example #1
0
        //Key 값이 8자리 정보

        public string result(DesType type, string input)
        {
            var des = new DESCryptoServiceProvider()
            {
                Key = Key,
                IV  = Key
            };

            var ms = new MemoryStream();

            //익명 타입으로 transform / data 정의
            var property = new
            {
                transform = type.Equals(DesType.Encrypt) ? des.CreateEncryptor() : des.CreateDecryptor(),
                data      = type.Equals(DesType.Encrypt) ? Encoding.UTF8.GetBytes(input.ToCharArray()) : Convert.FromBase64String(input)
            };

            var cryStream = new CryptoStream(ms, property.transform, CryptoStreamMode.Write);

            var data = property.data;

            cryStream.Write(data, 0, data.Length);
            cryStream.FlushFinalBlock();

            return(type.Equals(DesType.Encrypt) ? Convert.ToBase64String(ms.ToArray()) : Encoding.UTF8.GetString(ms.GetBuffer()));
        }
Example #2
0
        public CTransaction()
        {
            if (Esam.IsUse)
            {
                EnType = EncryptType.Hardware;
            }
            else
            {
                EnType = EncryptType.Soft;
            }

            DType  = (DesType)Global.gConfig.TransConfig.DESType;
            AlType = (AlgorithmType)Global.gConfig.TransConfig.AlgorithmType;
            if (DType == DesType.Des)
            {
                MasterKey = new byte[8];
                MasterKey = Utility.str2Bcd(Global.gConfig.TransConfig.MasterKey);
            }
            else if (DType == DesType.TripleDes)
            {
                MasterKey = new byte[16];
                MasterKey = Utility.str2Bcd(Global.gConfig.TransConfig.MasterKey);
            }

            TransUpPack                = new Iso8583Package(Global.gAppPath + "\\iso8583.xml");
            TransUpPack.SmartBitmap    = true;
            TransUpPack.MessageTypeLen = 4;

            TransDownPack                = new Iso8583Package(Global.gAppPath + "\\iso8583.xml");
            TransDownPack.SmartBitmap    = true;
            TransDownPack.MessageTypeLen = 4;
        }
Example #3
0
    static SupportTypeUtil()
    {
        IType type = new IntType();

        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new FloatType();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new StringType();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new ListIntType();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new ListStringType();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new ListFloatType();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new Vector2Type();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new Vector3Type();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new DesType();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new DictionaryIntIntType();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new DictionaryIntStringType();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
        type = new ListListStringType();
        _supportTypeMap.Add(type.lowerName, type);
        _suportTypeList.Add(type.realName);
    }
Example #4
0
        private void readConfig()
        {
            mSectionName = SectionName;
            if (!string.IsNullOrEmpty(mSectionName))
            {
                if (!mNameList.Contains(mSectionName))
                {
                    defaultPrepareConfig();
                    mNameList.Add(mSectionName);
                }
            }
            else
            {
                throw new Exception(this + "必须配置区间名");
            }

            mErrConfigFile = ReadIniFile("ErrConfFile");
            if (!string.IsNullOrEmpty(mErrConfigFile))
            {
                mErrConfigFile = Path.Combine(Application.StartupPath, mErrConfigFile);
            }
            else
            {
                mErrConfigFile = null;
            }
            mSchemaFile = ReadIniFile("SchemaFile");
            if (string.IsNullOrEmpty(mSchemaFile))
            {
                throw new Exception("报文域配置文件不能为空");
            }
            else
            {
                mSchemaFile = Path.Combine(Application.StartupPath, mSchemaFile);
            }

            if (ReadIniFile("Use") == "0")
            {
                RealEnv = false;
            }
            else
            {
                RealEnv = true;
            }
            if (Esam.IsUse)
            {
                EnType = EncryptType.Hardware;
            }
            string content = ReadIniFile("Des");

            if (content != "1" && content != "3")
            {
                throw new Exception("DES类型配置错误");
            }
            if (content == "1")
            {
                DType     = DesType.Des;
                KeyLength = 8;
            }
            content = ReadIniFile("MacAlgorithm");
            if (content != "1" && content != "2" && content != "3")
            {
                throw new Exception("MAC算法配置错误");
            }
            if (content == "2")
            {
                AlType = AlgorithmType.ECB;
            }
            else if (content == "3")
            {
                AlType = AlgorithmType.CBC;
            }

            if (RealEnv)
            {
                IPAddress.Parse(ReadIniFile("ServerIP"));
                serverIP    = ReadIniFile("ServerIP");
                serverPort  = int.Parse(ReadIniFile("ServerPort"));
                sendTimeOut = int.Parse(ReadIniFile("SendTimeOut"));
                recvTimeOut = int.Parse(ReadIniFile("RecvTimeOut"));
            }
        }
Example #5
0
 internal static string LinkDesigner(DesType DesignerType, int ItemID, string ItemLabel, string pathDesigner)
 {
     return(string.Format(" <a href=\"Javascript:EvoDico.edit('{0}','{2}ed_{0}.aspx?ID={1}','{3}')\" class=\"des-{0}\">&nbsp;</a>", DesignerType.ToString("G"), ItemID, pathDesigner, HttpUtility.HtmlEncode(ItemLabel)));
 }