Beispiel #1
0
        public static string Encrypt(EncryptFormat format, string text)
        {
            string encryptedText;

            switch (format)
            {
            case EncryptFormat.MD5:
                encryptedText = MD5(text);
                break;

            case EncryptFormat.SHA1:
                encryptedText = SHA1(text);
                break;

            case EncryptFormat.bbsMax:
                encryptedText = MD5(text);
                break;

            case EncryptFormat.Dvbbs:
                encryptedText = ASPMD5(text).Substring(8, 16);
                break;

            default:
                encryptedText = text;
                break;
            }
            return(encryptedText);
        }
Beispiel #2
0
        /// <summary>
        /// 输入的密码与数据库密码对比
        /// </summary>
        /// <param name="format">加密格式</param>
        /// <param name="inputPassword">用户输入的密码</param>
        /// <param name="userPassword">数据库存储的密码</param>
        /// <returns></returns>
        public static bool ComparePassword(EncryptFormat format, string inputPassword, string userPassword)
        {
            if (ComparePasswordWithoutEncode(format, inputPassword, userPassword))
            {
                return(true);
            }

            else if (ComparePasswordWithoutEncode(format, HttpUtility.HtmlEncode(inputPassword), userPassword))
            {
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// 输入的密码与数据库密码对比
        /// </summary>
        /// <param name="format">加密格式</param>
        /// <param name="inputPassword">用户输入的密码</param>
        /// <param name="userPassword">数据库存储的密码</param>
        /// <returns></returns>
        public static bool ComparePassword(EncryptFormat format, string inputPassword, string userPassword)
        {
            string encryptedUserPassowrd;

            if (EncryptFormat.Discuz == format)
            {
                encryptedUserPassowrd = userPassword.Substring(0, 6) + MD5(MD5(inputPassword).ToLower() + userPassword.Substring(0, 6));
            }
            else
            {
                encryptedUserPassowrd = Encrypt(format, inputPassword);
            }

            if (string.Compare(encryptedUserPassowrd, userPassword, format != EncryptFormat.Text) == 0)
            {
                return(true);
            }

            return(false);
        }
Beispiel #4
0
		public static string Encrypt(EncryptFormat format, string text)
		{
			string encryptedText;
			switch (format)
			{
				case EncryptFormat.MD5:
					encryptedText = MD5(text);
					break;
				case EncryptFormat.SHA1:
					encryptedText = SHA1(text);
					break;
				case EncryptFormat.bbsMax:
                    encryptedText = MD5(text);
                    break;
                case EncryptFormat.Dvbbs:
                    encryptedText = ASPMD5(text).Substring(8,16);
                    break;                
				default:
					encryptedText = text;
					break;
			}
			return encryptedText;
		}
Beispiel #5
0
        public static string Encrypt(EncryptFormat format, string text)
        {
            string encryptedText;

            switch (format)
            {
            case EncryptFormat.MD5:
                encryptedText = MD5(text);
                break;

            case EncryptFormat.SHA1:
                encryptedText = SHA1(text);
                break;

            case EncryptFormat.TuanLet:
                encryptedText = MD5(text);
                break;

            default:
                encryptedText = text;
                break;
            }
            return(encryptedText);
        }
Beispiel #6
0
        private static bool ComparePasswordWithoutEncode(EncryptFormat format, string inputPassword, string userPassword)
        {
            string encryptedUserPassowrd;

            if (EncryptFormat.MolyX == format)//molyx的加密方法MD5(MD5(password)+salt)
            {
                encryptedUserPassowrd = userPassword.Substring(0, 5) + MD5(MD5(inputPassword).ToLower() + userPassword.Substring(0, 5));
            }
            else if (EncryptFormat.Discuz == format)
            {
                encryptedUserPassowrd = userPassword.Substring(0, 6) + MD5(MD5(inputPassword).ToLower() + userPassword.Substring(0, 6));
            }
            else
            {
                encryptedUserPassowrd = Encrypt(format, inputPassword);
            }

            if (string.Compare(encryptedUserPassowrd, userPassword, format != EncryptFormat.ClearText) == 0)
            {
                return(true);
            }

            return(false);
        }
Beispiel #7
0
        private static bool ComparePasswordWithoutEncode(EncryptFormat format, string inputPassword, string userPassword)
        {
            string encryptedUserPassowrd;
            if (EncryptFormat.MolyX == format)//molyx的加密方法MD5(MD5(password)+salt)
                encryptedUserPassowrd = userPassword.Substring(0, 5) + MD5(MD5(inputPassword).ToLower() + userPassword.Substring(0, 5));
            else if (EncryptFormat.Discuz == format)
                encryptedUserPassowrd = userPassword.Substring(0, 6) + MD5(MD5(inputPassword).ToLower() + userPassword.Substring(0, 6));
            else
                encryptedUserPassowrd = Encrypt(format, inputPassword);

            if (string.Compare(encryptedUserPassowrd, userPassword, format != EncryptFormat.ClearText) == 0)
                return true;

            return false;
        }
Beispiel #8
0
        /// <summary>
        /// 输入的密码与数据库密码对比
        /// </summary>
        /// <param name="format">加密格式</param>
        /// <param name="inputPassword">用户输入的密码</param>
        /// <param name="userPassword">数据库存储的密码</param>
        /// <returns></returns>
        public static bool ComparePassword(EncryptFormat format, string inputPassword, string userPassword)
        {
            if (ComparePasswordWithoutEncode(format, inputPassword, userPassword))
                return true;

            else if (ComparePasswordWithoutEncode(format, HttpUtility.HtmlEncode(inputPassword), userPassword))
                return true;

            return false;
        }
Beispiel #9
0
 /// <summary>
 /// 用户注册
 /// </summary>
 public abstract int Register(ref int userID, string username, string email, string password, EncryptFormat passwordFormat, UserRoleCollection initRoles, string ip, Guid?serial, int inviterID, bool IsActive, int[] userPoints, int ipInterval);
Beispiel #10
0
 /// <summary>
 /// 修改用户密码
 /// </summary>
 public abstract void ResetUserPassword(int userID, string encodedPassword, EncryptFormat format);