生成16位不重复编码

        /// <summary>
        /// 生成16位不重复编码
        /// </summary>
        /// <returns>string</returns>
        public static string BuilderGuidTo16()
        {
            long i = 1;
            char[] az = "GFDSAHJKLMTREWQYUIOPNBVCXZ".ToCharArray();

            foreach (byte byt in Guid.NewGuid().ToByteArray())
            {
                i *= ((int)byt + 1);
            }

            string result = string.Format("{0:x}", i - DateTime.Now.Ticks);

            while (result.Length < 16)
            {
                result += az[new Random().Next(0, 25)];
            }

            return result;
        }

  

posted @ 2014-04-24 17:12  Mr.Tom  阅读(1459)  评论(0编辑  收藏  举报