Ejemplo n.º 1
0
        /// <summary>
        /// Convert a hexadecimal id into a base-62 encoded id.
        /// </summary>
        /// <param name="hex">A hexadecimal id.</param>
        /// <returns>A base-62 encoded id.</returns>
        private static string ToBase62(string hex)
        {
            string uri = BaseConvert.Convert(hex, 16, 62);

            /* Prepend zeroes until base-62 string length is 22. */
            while (uri.Length < 22)
            {
                uri.Insert(0, "0");
            }

            return(uri);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Convert a base-62 encoded id into a hexadecimal id.
        /// </summary>
        /// <param name="base62">A base-62 encoded id.</param>
        /// <returns>A hexadecimal id.</returns>
        private static string ToHex(string base62)
        {
            string hex = BaseConvert.Convert(base62, 62, 16);

            /* Prepend zeroes until hexadecimal string length is 32. */
            while (hex.Length < 32)
            {
                hex.Insert(0, "0");
            }

            return(hex);
        }