Beispiel #1
0
        /// <summary>
        /// 得到输入字符串哈希值的长度
        /// </summary>
        /// <param name="input"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static decimal GetHashKey(string input, StringFilterOptions options)
        {
            ulong num;

            if (string.IsNullOrEmpty(input))
            {
                return(0M);
            }
            input = FilterInvalidChar(input, options);
            var data      = Encoding.UTF8.GetBytes(input);
            var encryData = Md5.Encrypt(data);

            num = BitConverter.ToUInt64(encryData, 4);
            return(DataConverter.CDecimal(num));
        }
Beispiel #2
0
        /// <summary>
        /// 得到以数字9开头,长度在9位以内的数字
        /// 1、对输入的字符串进行MD5加密
        /// 2、长度大于等于9位时,返回"9" + input.Substring(1, 8)
        /// 3、长度小于9位时,返回"9" + input
        /// </summary>
        /// <param name="strText"></param>
        /// <returns></returns>
        public static int MD5D(string strText)
        {
            var           data      = Encoding.UTF8.GetBytes(strText);
            var           encryData = Md5.Encrypt(data);
            StringBuilder builder   = new StringBuilder();

            foreach (byte num in encryData)
            {
                builder.Append(num.ToString("D", CultureInfo.CurrentCulture).ToLower());
            }
            string input = builder.ToString();

            if (input.Length >= 9)
            {
                input = "9" + input.Substring(1, 8);
            }
            else
            {
                input = "9" + input;
            }
            return(DataConverter.CLng(input));
        }