Beispiel #1
0
        private AccountItem FormatPwd(AccountItem account)
        {
            const string AddChar = "a";
            const int    AddNum  = 1;
            string       oldPwd  = account.Password;

            foreach (PwdFormatOptions item in this.HttperParamsItem.PwdFormatOptions)
            {
                switch (item)
                {
                case PwdFormatOptions.FirstCharReversal:
                    char c = TextHelper.CharReversal(oldPwd[0]);
                    if (c != account.Password[0])
                    {
                        account.Password = string.Format("{0}{1}", c, oldPwd.Substring(1));
                    }
                    break;

                case PwdFormatOptions.AddOneAfterEndWithNum:
                    bool isNum = TextHelper.IsNumber(oldPwd[oldPwd.Length - 1]);
                    if (isNum)
                    {
                        account.Password = string.Format("{0}{1}", account.Password, AddNum);
                    }
                    break;

                case PwdFormatOptions.AddAAfterEndWithChar:
                    bool isChar = TextHelper.IsChar(oldPwd[oldPwd.Length - 1]);
                    if (isChar)
                    {
                        account.Password = string.Format("{0}{1}", account.Password, AddChar);
                    }
                    break;

                case PwdFormatOptions.AddAAllNum:
                    bool isAllNum = TextHelper.IsNumber(oldPwd);
                    if (isAllNum)
                    {
                        account.Password = string.Format("{0}{1}", account.Password, AddChar);
                    }
                    break;

                case PwdFormatOptions.AddOneAllChar:
                    bool isAllChar = TextHelper.IsAllChar(oldPwd);
                    if (isAllChar)
                    {
                        account.Password = string.Format("{0}{1}", account.Password, AddNum);
                    }
                    break;

                case PwdFormatOptions.RawAddFirstCharReversal:
                    char firstChar = TextHelper.CharReversal(oldPwd[0]);
                    account.Password = string.Format("{0}{1}", account.Password, firstChar);
                    break;

                default:
                    break;
                }
            }
            return(account);
        }