Beispiel #1
0
 /// <summary>
 /// 用M004加密
 /// </summary>
 /// <param name="strSource"></param>
 /// <returns></returns>
 public static string EncryptWithM004(string strSource)
 {
     try
     {
         return(ServerAESEncryption.EncryptString(strSource, EncryptionMode.AES256V04Hex));
     }
     catch
     {
         return(strSource);
     }
 }
Beispiel #2
0
 private string EncryptString01(string strSource)
 {
     try
     {
         return(ServerAESEncryption.EncryptString(strSource, EncryptionMode.AES256V01Hex));
     }
     catch
     {
         return(strSource);
     }
 }
Beispiel #3
0
 void BtnGetOpt006_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string strOptID    = TxtSource.Text;
         long   optID       = long.Parse(strOptID);
         long   licID       = optID + 1000000000;
         string strDatetime = DateTime.Parse("2015-01-01").ToString("yyyy/MM/dd HH:mm:ss");
         string str         = string.Format("{0}{1}{2}{1}N", licID, ConstValue.SPLITER_CHAR, strDatetime);
         str = ServerAESEncryption.EncryptString(str, EncryptionMode.AES256V02Hex);
         AppendMessage(str);
     }
     catch (Exception ex)
     {
         AppendMessage(ex.Message);
     }
 }
Beispiel #4
0
 public string EncryptString(string source, int mode, Encoding encoding)
 {
     return(ServerAESEncryption.EncryptString(source, (EncryptionMode)mode, encoding));
 }
Beispiel #5
0
 public string EncryptString(string source, int mode)
 {
     //return source;
     return(ServerAESEncryption.EncryptString(source, (EncryptionMode)mode, Encoding.ASCII));
 }
Beispiel #6
0
        private OperationReturn ModifyUserPasswordM003(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listParams.Count < 3)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param count invalid");
                    return(optReturn);
                }
                string strID, method, password;
                //0         UserID
                //1         Method(0:使用默认密码;1:使用指定的密码;2:特殊情况,19位用户编号+默认密码)
                //2         密码
                strID    = listParams[0];
                method   = listParams[1];
                password = listParams[2];
                string         rentToken = session.RentInfo.Token;
                string         passToDB;
                string         strSql;
                DataSet        objDataSet = null;
                EncryptionMode mode       = (EncryptionMode)Enum.Parse(typeof(EncryptionMode), "AES256V03Hex");
                if (method == "0")
                {
                    //从全局参数表查得默认密码
                    switch (session.DBType)
                    {
                    case 2:
                        strSql =
                            string.Format("SELECT C006 FROM T_11_001_{0} WHERE C002 = 11 AND C003 = {1}"
                                          , rentToken
                                          , S1101Consts.PARAM_DEFAULT_PASSWORD);
                        optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        objDataSet = optReturn.Data as DataSet;
                        break;

                    case 3:
                        strSql =
                            string.Format("SELECT C006 FROM T_11_001_{0} WHERE C002 = 11 AND C003 = {1}"
                                          , rentToken
                                          , S1101Consts.PARAM_DEFAULT_PASSWORD);
                        optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        objDataSet = optReturn.Data as DataSet;
                        break;
                    }
                    if (objDataSet == null)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_OBJECT_NULL;
                        optReturn.Message = string.Format("DataSet is null");
                        return(optReturn);
                    }
                    if (objDataSet.Tables[0].Rows.Count <= 0)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_DBACCESS_NOT_EXIST;
                        optReturn.Message = string.Format("Globle param not exist.");
                        return(optReturn);
                    }
                    string defaultPass = objDataSet.Tables[0].Rows[0]["C006"].ToString();
                    defaultPass = DecryptFromDB(defaultPass);
                    defaultPass = defaultPass.Substring(8);
                    passToDB    = ServerAESEncryption.EncryptString(strID + defaultPass, mode);
                }
                else
                {
                    passToDB = ServerAESEncryption.EncryptString(strID + password, mode);
                }
                if (string.IsNullOrEmpty(passToDB))
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_STRING_EMPTY;
                    optReturn.Message = string.Format("Password to database is empty");
                    return(optReturn);
                }
                switch (session.DBType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "UPDATE T_11_005_{0} SET C004 = '{1}', C023 = '{2}' WHERE C001 = {3}",
                            rentToken,
                            passToDB,
                            DateTime.Now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss"),
                            strID);
                    optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "UPDATE T_11_005_{0} SET C004 = '{1}', C023 = TO_DATE('{2}','YYYY-MM-DD HH24:MI:SS') WHERE C001 = {3}",
                            rentToken,
                            passToDB,
                            DateTime.Now.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss"),
                            strID);
                    optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Beispiel #7
0
        void BtnEncrypt_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var typeItem = ListBoxType.SelectedItem as EncryptionTypeItem;
                var modeItem = ComboMode.SelectedItem as EncryptionModeItem;
                var encItem  = ListBoxEncoding.SelectedItem as EncryptionEncodingItem;
                if (typeItem == null || modeItem == null || encItem == null)
                {
                    return;
                }

                string strSource = TxtSource.Text;
                string strReturn = string.Empty;
                //string strTemp;

                int      mode     = (int)modeItem.Mode;
                int      type     = mode / 1000;
                Encoding encoding = encItem.Encoding;
                switch (type)
                {
                case 1:
                    //do
                    //{
                    //    if (strSource.Length > 128)
                    //    {
                    //        strTemp = strSource.Substring(0, 128);
                    //        strSource = strSource.Substring(128, strSource.Length - 128);
                    //    }
                    //    else
                    //    {
                    //        strTemp = strSource;
                    //        strSource = string.Empty;
                    //    }
                    //    if (typeItem.Value == 1)
                    //    {
                    //        strReturn += ClientAESEncryption.EncryptString(strTemp, modeItem.Mode, encoding);
                    //    }
                    //    else
                    //    {
                    //        strReturn += ServerAESEncryption.EncryptString(strTemp, modeItem.Mode, encoding);
                    //    }

                    //} while (strSource.Length > 0);
                    if (typeItem.Value == 1)
                    {
                        strReturn += ClientAESEncryption.EncryptString(strSource, modeItem.Mode, encoding);
                    }
                    else
                    {
                        strReturn += ServerAESEncryption.EncryptString(strSource, modeItem.Mode, encoding);
                    }
                    break;

                case 2:
                case 3:
                    if (typeItem.Value == 1)
                    {
                        strReturn += ClientHashEncryption.EncryptString(strSource, modeItem.Mode, encoding);
                    }
                    else
                    {
                        strReturn += ServerHashEncryption.EncryptString(strSource, modeItem.Mode, encoding);
                    }
                    break;

                default:
                    ShowErrorMessage(string.Format("EncryptMode invalid.\t{0}", modeItem.Mode));
                    return;
                }
                AppendMessage(strReturn);
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex.Message);
            }
        }