Exemplo n.º 1
0
        /// <summary>
        /// For internal use; use the parameterless overload for effeciency.
        /// </summary>
        /// <param name="host"></param>
        /// <returns></returns>
        public static string ComputeHostHash(string host)
        {
            long   sum  = new long?(getBytesSum(computeMd5(host), 36, 2)).Value;
            string hash = Base36Converter.Encode(sum);

            return(hash);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Compresses the MD5 of this server's hostname by summing the bytes until the sum
        /// fits into two Base36 characters (<= 36^2, or 1296):
        /// </summary>
        /// <returns>2 character Base36 checksum of MD5 of hostname</returns>
        public static string ComputeHostHash()
        {
            string hash = Base36Converter.Encode(
                (_hostSum.HasValue ? _hostSum.Value : (
                     _hostSum = new long?(getBytesSum(computeMd5(getHostBytes()), 36, 2))).Value));

            return(hash);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a random Base36 number 3 characters long.
        /// </summary>
        /// <returns></returns>
        private static string getRandomDigits()
        {
            Int32 rndInt;

            lock (_lockObj)
            {
                rndInt = _rnd.Next(46655);
            }
            return(Base36Converter.Encode(rndInt));
        }