void LoadConfigDBList() { bllDataBaseList bll = new bllDataBaseList(); DataTable dt = bll.GetUserDBList(Loginer.CurrentLoginer.Account); foreach (DataRow dr in dt.Rows) { string DBCode = ConvertLib.ToString(dr[sys_DataBaseList.DBCode]); string DBConnection = Encrypt.DESDecrypt(ConvertLib.ToString(dr[sys_DataBaseList.DBConnection]), Globals.KeyConnectionStr); string DBProviderName = ConvertLib.ToString(dr[sys_DataBaseList.DBProviderName]); dic.Add(DBCode, new DabaBaseModel() { ConnnectionString = DBConnection, ProviderName = DBProviderName }); } }
protected void DoSignInSucc() { string time = RecvPackage.GetString(12); //时间 string date = RecvPackage.GetString(13); //日期 SetBatchNo(RecvPackage.GetString(60).Substring(2, 6)); //记录批次号 byte[] bField62 = new byte[0]; bField62 = Utility.str2Bcd(RecvPackage.GetString(62)); byte[] EPinkey = new byte[KeyLength]; byte[] EMackey = new byte[KeyLength]; switch (DType) { case DesType.Des: Array.Copy(bField62, 0, EPinkey, 0, KeyLength); Array.Copy(bField62, 12, EMackey, 0, KeyLength); break; case DesType.TripleDes: Array.Copy(bField62, 0, EPinkey, 0, KeyLength); Array.Copy(bField62, 20, EMackey, 0, 8); Array.Copy(bField62, 20, EMackey, 8, 8); break; } KeyManager.SetEnMacKey(SectionName, EMackey); KeyManager.SetEnPinKey(SectionName, EPinkey); //Log.Debug("MackeyEn:" + Utility.bcd2str(EMackey, EMackey.Length)); //Log.Debug("PinkeyEn:" + Utility.bcd2str(EPinkey, EPinkey.Length)); byte[] PinKey = null, WorkKey = null; if (EnType == EncryptType.Soft) { byte[] MasterKey = GetSoftMasterKey(); if (DType == DesType.Des) { PinKey = Encrypt.DESDecrypt(EPinkey, MasterKey); WorkKey = Encrypt.DESDecrypt(EMackey, MasterKey); } else if (DType == DesType.TripleDes) { PinKey = Encrypt.DES3Decrypt(EPinkey, MasterKey); WorkKey = Encrypt.DES3Decrypt(EMackey, MasterKey); } } else { PinKey = new byte[KeyLength]; WorkKey = new byte[KeyLength]; Esam.SetWorkmode(Esam.WorkMode.Encrypt); Esam.UserDecrypt(GetKeyIndex(), EPinkey, KeyLength, PinKey); Esam.UserDecrypt(GetKeyIndex(), EMackey, KeyLength, WorkKey); Esam.SetWorkmode(Esam.WorkMode.Default); } KeyManager.SetDeMacKey(SectionName, WorkKey); KeyManager.SetDePinKey(SectionName, PinKey); if (!CheckKeyValue()) { SetResult(TransResult.E_KEYVERIFY_FAIL); } else { //更新当前机器时间 int year = System.DateTime.Now.Year; int month = Convert.ToInt32(date.Substring(0, 2)); int day = Convert.ToInt32(date.Substring(2, 2)); int hour = Convert.ToInt32(time.Substring(0, 2)); int mi = Convert.ToInt32(time.Substring(2, 2)); int ss = Convert.ToInt32(time.Substring(4, 2)); DateTime newDt = new DateTime(year, month, day, hour, mi, ss); #if !DEBUG Utility.SetSysTime(newDt); #endif } }
protected void DoSignInSucc() { var time = RecvPackage.GetString(12); //时间 var date = RecvPackage.GetString(13); //日期 SetBatchNo(RecvPackage.GetString(60).Substring(2, 6)); //记录批次号 var bField62 = new byte[0]; bField62 = RecvPackage.GetArrayData(62); // Utility.str2Bcd(RecvPackage.GetString(62)); var EPinkey = new byte[KeyLength]; var EMackey = new byte[KeyLength]; var ETrakey = new byte[KeyLength]; switch (DType) { case DesType.Des: //目前不支持des单倍长 Array.Copy(bField62, 0, EPinkey, 0, KeyLength); Array.Copy(bField62, 12, EMackey, 0, KeyLength); break; case DesType.TripleDes: Array.Copy(bField62, 1, EPinkey, 0, 16); Array.Copy(bField62, 21, EMackey, 0, 16); Array.Copy(bField62, 41, ETrakey, 0, 16); break; } KeyManager.SetEnMacKey(SectionName, EMackey); KeyManager.SetEnPinKey(SectionName, EPinkey); KeyManager.SetEnTraKey(SectionName, ETrakey); //Log.Debug("MackeyEn:" + Utility.bcd2str(EMackey, EMackey.Length)); //Log.Debug("PinkeyEn:" + Utility.bcd2str(EPinkey, EPinkey.Length)); byte[] PinKey = null, WorkKey = null, TraKey = null; if (EnType == EncryptType.Soft) { var MasterKey = GetSoftMasterKey(); if (DType == DesType.Des) { PinKey = Encrypt.DESDecrypt(EPinkey, MasterKey); WorkKey = Encrypt.DESDecrypt(EMackey, MasterKey); TraKey = Encrypt.DESDecrypt(ETrakey, MasterKey); } else if (DType == DesType.TripleDes) { PinKey = Encrypt.DES3Decrypt(EPinkey, MasterKey); WorkKey = Encrypt.DES3Decrypt(EMackey, MasterKey); TraKey = Encrypt.DES3Decrypt(ETrakey, MasterKey); } } else { PinKey = new byte[KeyLength]; WorkKey = new byte[KeyLength]; TraKey = new byte[KeyLength]; Esam.SetWorkmode(Esam.WorkMode.Encrypt); Esam.UserDecrypt(GetKeyIndex(), EPinkey, KeyLength, PinKey); Esam.UserDecrypt(GetKeyIndex(), EMackey, KeyLength, WorkKey); Esam.UserDecrypt(GetKeyIndex(), ETrakey, KeyLength, TraKey); Esam.SetWorkmode(Esam.WorkMode.Default); } KeyManager.SetDeMacKey(SectionName, WorkKey); KeyManager.SetDePinKey(SectionName, PinKey); KeyManager.SetDeTraKey(SectionName, TraKey); if (!CheckKeyValue()) { SetResult(TransResult.E_KEYVERIFY_FAIL); } else { ////更新当前机器时间 //var year = DateTime.Now.Year; //var month = Convert.ToInt32(date.Substring(0, 2)); //var day = Convert.ToInt32(date.Substring(2, 2)); //var hour = Convert.ToInt32(time.Substring(0, 2)); //var mi = Convert.ToInt32(time.Substring(2, 2)); //var ss = Convert.ToInt32(time.Substring(4, 2)); } }
protected void DoSignInSucc() { string time = RecvPackage.GetString(12); //时间 string date = RecvPackage.GetString(13); //日期 //SetBatchNo(RecvPackage.GetString(37).Substring(2, 6));//记录批次号 byte[] bField60 = new byte[0]; bField60 = Utility.str2Bcd(RecvPackage.GetString(60)); //bField60 = RecvPackage.GetArrayData(60); byte[] EPinkey = new byte[KeyLength]; byte[] EMackey = new byte[KeyLength]; Array.Copy(bField60, 0, EPinkey, 0, KeyLength); Array.Copy(bField60, 8, EMackey, 0, KeyLength); KeyManager.SetEnMacKey(SectionName, EMackey); KeyManager.SetEnPinKey(SectionName, EPinkey); byte[] bTerminalNo = Encoding.Default.GetBytes(GetTerminalNo()); byte[] PinKey = null, WorkKey = null; if (EnType == EncryptType.Soft) { byte[] MasterKey = GetSoftMasterKey(); if (DType == DesType.Des) { byte[] EPinkeytmp = EPinkey; byte[] EMackeytmp = EMackey; byte[] tmp = Encrypt.DESEncrypt(EPinkeytmp, MasterKey); PinKey = Encrypt.DESDecrypt(tmp, bTerminalNo); tmp = Encrypt.DESEncrypt(EMackeytmp, MasterKey); WorkKey = Encrypt.DESDecrypt(tmp, bTerminalNo); } else if (DType == DesType.TripleDes) { PinKey = Encrypt.DES3Decrypt(EPinkey, MasterKey); WorkKey = Encrypt.DES3Decrypt(EMackey, MasterKey); } } else { PinKey = new byte[KeyLength]; WorkKey = new byte[KeyLength]; Esam.SetWorkmode(Esam.WorkMode.Encrypt); byte[] tempkey = new byte[8]; Esam.UserEncrypt(GetKeyIndex(), EPinkey, KeyLength, tempkey); //Esam.Encrypt(EPinkey, 8, tempkey); PinKey = Encrypt.DESDecrypt(tempkey, bTerminalNo); Esam.UserEncrypt(GetKeyIndex(), EMackey, KeyLength, tempkey); //Esam.Encrypt(EMackey, 8, tempkey); WorkKey = Encrypt.DESDecrypt(tempkey, bTerminalNo); Esam.SetWorkmode(Esam.WorkMode.Default); } KeyManager.SetDeMacKey(SectionName, WorkKey); KeyManager.SetDePinKey(SectionName, PinKey); Log.Info("download pinKey:" + Utility.bcd2str(PinKey, PinKey.Length)); Log.Info("download macKey:" + Utility.bcd2str(WorkKey, WorkKey.Length)); //更新当前机器时间 int year = System.DateTime.Now.Year; int month = Convert.ToInt32(date.Substring(4, 2)); int day = Convert.ToInt32(date.Substring(6, 2)); int hour = Convert.ToInt32(time.Substring(0, 2)); int mi = Convert.ToInt32(time.Substring(2, 2)); int ss = Convert.ToInt32(time.Substring(4, 2)); DateTime newDt = new DateTime(year, month, day, hour, mi, ss); #if !DEBUG Utility.SetSysTime(newDt); #endif // } }