EncryptString() static private method

static private EncryptString ( string plainText, Array, Key, Array, IV ) : byte[]
plainText string
Key Array,
IV Array,
return byte[]
Ejemplo n.º 1
0
        public APIJsonResult Edit(AdminUserEditModel adminUserModel)
        {
            var adminUserBLL = new TAdminUserBLL();
            var adminUser    = adminUserBLL.Find(u => u.ID == adminUserModel.ID);

            AddUpdateInfo(adminUser);

            List <string> updatedField = new List <string>();

            if (!string.IsNullOrEmpty(adminUserModel.Password))
            {
                adminUser.Password = EncryptHelper.EncryptString(adminUserModel.Password);
            }

            adminUser.Status = adminUserModel.Status;

            adminUserBLL.SaveChanges();

            var adminUserRoleBLL = new TAdminUserRoleBLL();
            var adminUserRole    = adminUserRoleBLL.Find(r => r.AdminUserID == adminUser.ID);

            adminUserRole.RoleID = adminUserModel.RoleID;

            AddUpdateInfo(adminUserRole);
            adminUserRoleBLL.SaveChanges();

            return(Success());
        }
Ejemplo n.º 2
0
        public APIJsonResult Add(AdminUserRegModel adminUserModel)
        {
            var adminUserBLL = new TAdminUserBLL();


            var adminUser = new TAdminUser()
            {
                Account  = adminUserModel.Account.Trim(),
                Password = EncryptHelper.EncryptString(adminUserModel.Password),
                Status   = adminUserModel.Status
            };

            AddCreateInfo(adminUser);

            var role = new TAdminUserRole()
            {
                RoleID = adminUserModel.RoleID
            };

            AddCreateInfo(role);
            try {
                adminUserBLL.Register(adminUser, role);
            }
            catch (ValidationException ex)
            {
                return(Failed(ex.Message));
            }

            return(Success());
        }
Ejemplo n.º 3
0
        public IActionResult Create(SubmitForm rescoure)
        {
            EncryptHelper EncryptHelper = new EncryptHelper(CommonConst.API_ENCRYPT_KEY);
            string        data          = JsonConvert.SerializeObject(rescoure);
            string        dataEncrypt   = EncryptHelper.EncryptString(data);

            return(RedirectToAction("Payment", new { token = dataEncrypt }));
        }
Ejemplo n.º 4
0
    public static void SaveDataWithEncrypt <T>(T data, string path)
    {
        var    newPath    = Path.Combine(Application.persistentDataPath, path);
        string jsonString = JsonUtility.ToJson(data);

        using (StreamWriter streamWriter = File.CreateText(newPath))
        {
            var s = EncryptHelper.EncryptString(jsonString);
            streamWriter.Write(s);
        }
    }
Ejemplo n.º 5
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="managerInfo">ManagerInfo类型的对象</param>
 /// <returns>受影响行数</returns>
 public int InsertManagerInfo(ManagerInfo managerInfo)
 {
     sql = "Insert into ManagerInfo(mname,mpwd,mtype) Values(@name,@password,@type)";
     SQLiteParameter[] sp =
     {
         new SQLiteParameter("@name",     managerInfo.ManagerName),
         new SQLiteParameter("@password", EncryptHelper.EncryptString(managerInfo.ManagerPassword)),
         new SQLiteParameter("@type",     managerInfo.ManagerType)
     };
     return(SQLiteHelper.ExecuteNonQuery(sql, sp));
 }
Ejemplo n.º 6
0
        public void test()
        {
            string    strSql = "select * from users";
            DataTable dt     = OracleHelper.ExecuteDataTable(strSql);

            string[] sSql = new string[dt.Rows.Count];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sSql[i] = "update users set Password = '******' where userName = '******'";
                sSql[i] = string.Format(sSql[i], EncryptHelper.EncryptString(dt.Rows[i]["userName"].ToString()), dt.Rows[i]["userName"].ToString());
            }
            OracleHelper.ExecuteCommand(sSql);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            var content = "Example test";
            //var key = "E546C8DF278CD5931069B522E695D4F2";
            var key = Guid.NewGuid().ToString().Replace("-", "");

            Console.WriteLine(content);
            var encrypted = EncryptHelper.EncryptString(content, key);

            Console.WriteLine(encrypted);

            // var decrypted = EncryptHelper.DecryptString(encrypted, key);
            //Console.WriteLine(decrypted);

            Console.ReadLine();
        }
Ejemplo n.º 8
0
        public List <SelectListItem> GetProductByCatalog(string catalogId)
        {
            var            list = new List <SelectListItem>();
            SelectListItem option;
            var            productList = this.Get().Where(p => p.CatalogId == catalogId.ToUpper()).ToList();

            foreach (Product item in productList)
            {
                option       = new SelectListItem();
                option.Text  = item.Name;
                option.Value =
                    EncryptHelper.EncryptString(item.Id.ToString());

                list.Add(option);
            }

            return(list);
        }
Ejemplo n.º 9
0
        public List <SelectListItem> GetCatalogSelectList()
        {
            List <SelectListItem> list = new List <SelectListItem>();
            SelectListItem        option;
            var catalogList = this.GetCatalog();

            foreach (ProductCatalog item in catalogList)
            {
                option       = new SelectListItem();
                option.Text  = item.Name;
                option.Value =
                    EncryptHelper.EncryptString(item.Id.ToString().ToUpper());

                list.Add(option);
            }

            return(list);
        }
Ejemplo n.º 10
0
        public bool ChanagePassWord(string userId, string OldPws, string NewPws, out string Message)
        {
            string strSql = string.Empty;

            strSql = "select * from users where userId = {0} and PassWord ='******'";
            strSql = string.Format(strSql, userId, EncryptHelper.EncryptString(OldPws.Trim()));
            DataTable dt = OracleHelper.ExecuteDataTable(strSql);

            if (dt.Rows.Count == 0)
            {
                Message = "原密码错误";
                return(false);
            }
            strSql  = "Update users Set PassWord = '******' where userId = {0}";
            strSql  = string.Format(strSql, userId, EncryptHelper.EncryptString(NewPws.Trim()));
            Message = string.Empty;
            return(OracleHelper.ExecuteCommand(strSql));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 登录系统
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public Users GetLoginUser(string loginName, string pwd, string cCode)
        {
            Users  user   = new Users();
            string strSql = "select * from users a left join company b on a.cCode = b.cCode "
                            + " left join department c on  c.DeptCode = a.DeptCode "
                            + " where a.UserName = '******' and a.Password = '******' and substr(a.ccode,0,4) = '{2}'";

            strSql = string.Format(strSql, loginName, EncryptHelper.EncryptString(pwd), cCode.Substring(0, 4));
            DataTable dt = OracleHelper.ExecuteDataTable(strSql);

            if (dt.Rows.Count == 1)
            {
                user.UserId = dt.Rows[0]["UserId"].ToString();
                ////单位
                user.Company.CompanyCode = dt.Rows[0]["cCode"].ToString();
                user.Company.Name        = dt.Rows[0]["CName"].ToString();
                user.Company.CompanyType = dt.Rows[0]["cType"].ToString();
                ////部门
                user.DepartMent.DeptCode = dt.Rows[0]["DeptCode"].ToString();
                user.DepartMent.DeptName = dt.Rows[0]["DeptName"].ToString();
                BusiUserService userService = new BusiUserService();
                string[]        roleAry     = userService.GetUserRoles(dt.Rows[0]["UserId"].ToString());
                ////角色
                user.Role.RoleId   = roleAry[0];
                user.Role.RoleName = roleAry[1];
                user.Role.RoleKey  = roleAry[2];
                ////用户基本信息
                user.UserName  = dt.Rows[0]["UserName"].ToString();
                user.RealName  = dt.Rows[0]["RealName"].ToString();
                user.TelePhone = dt.Rows[0]["TelePhone"].ToString();
                user.Sex       = dt.Rows[0]["Sex"].ToString().Equals("0");
                user.State     = dt.Rows[0]["State"].ToString().Equals("0");
            }
            else
            {
                user = null;
            }
            return(user);
        }
Ejemplo n.º 12
0
        public APIJsonResult Login(LoginModel adminUserModel)
        {
            var adminUser = adminUserBLL.Find(user => user.Account == adminUserModel.Account && user.Status == UserStatusList.Active);

            if (adminUser == null || !UtilHelper.CompareString(adminUser.Password, EncryptHelper.EncryptString(adminUserModel.Password)))
            {
                return(Failed("Account and password do not match."));
            }

            adminUser.LastLoginDate = DateTime.Now;
            adminUser.LastLoginIP   = Request.ServerVariables.Get("Remote_Addr").ToString();
            adminUser.Token         = LoginManager.GenerateToken();
            adminUser.TokenExpired  = DateTime.Now.AddHours(2);
            adminUserBLL.SaveChanges();

            LoginManager.SaveLoginUser(adminUser);



            return(Success("", new {
                Token = adminUser.Token,
                AdminUser = LoginManager.GetLoginUser(adminUser.Token)
            }));
        }
Ejemplo n.º 13
0
 /// <summary>
 ///     给一个字符串进行MD5加密
 /// </summary>
 /// <param name="strText">待加密字符串</param>
 /// <returns>加密后的字符串</returns>
 public static string MD5Encrypt(string strText)
 {
     return(EncryptHelper.EncryptString(strText, CONST_DEFAULT_ENCRYPT_KEY));
 }
Ejemplo n.º 14
0
        public bool ManageCompany(Company com)
        {
            string[] strSql = null;
            switch (com.Action)
            {
            case ActionEnum.Insert:

                strSql = new string[3];

                strSql[0] = "insert into Company"
                            + " select '{0}','{1}','{2}','{3}','{4}','{5}',"
                            + " nvl(Max(OrderNo),0) + 1 OrderNo from Company "
                            + " where substr(ShortcCode, 0, {6}) = '{7}' and length(ShortcCode) = {8}";

                strSql[0] = string.Format(strSql[0], com.CompanyCode, com.ShortCcode, com.CompanyType, com.Name, com.NameJc, com.Description,
                                          com.ParentCode.Length.ToString(), com.ParentCode, (com.ParentCode.Length + 2).ToString(), com.CompanyCode);
                strSql[1] = "insert into users (userId,ccode,userName,password,realname,sex,state,createdate) values ({0},'{1}','{2}','{3}','{4}',{5},{6},{7})";
                strSql[1] = string.Format(strSql[1], com.CompanyCode, com.CompanyCode, com.CompanyCode, EncryptHelper.EncryptString(com.CompanyCode), "系统管理员",
                                          "0", "0", "sysdate");
                strSql[2] = "Insert into usersandrole values ({0},'{1}')";
                strSql[2] = string.Format(strSql[2], com.CompanyCode, "1");
                break;

            case ActionEnum.Update:
                strSql    = new string[1];
                strSql[0] = "Update Company set CType = '{1}',cName = '{2}',cNameJC = '{3}',cDescription = '{4}' Where ShortcCode = '{0}'";
                strSql[0] = string.Format(strSql[0], com.ShortCcode, com.CompanyType, com.Name, com.NameJc, com.Description);
                break;

            case ActionEnum.Delete:
                strSql    = new string[3];
                strSql[0] = "delete from Company Where CCODE = '{0}'";
                strSql[0] = string.Format(strSql[0], com.CompanyCode);
                strSql[1] = "delete from usersandrole where userId in (select userid from users where UserName = '******')";
                strSql[1] = string.Format(strSql[1], com.CompanyCode);
                strSql[2] = "delete from users where UserName = '******'";
                strSql[2] = string.Format(strSql[2], com.CompanyCode);

                break;
            }
            return(OracleHelper.ExecuteCommand(strSql));
        }